View source: R/k-ontram_methods.R
warmstart.k_ontram_ci | R Documentation |
Set initial weights
## S3 method for class 'k_ontram_ci'
warmstart(
object,
thetas = NULL,
betas = NULL,
which = c("all", "baseline only", "shift only")
)
thetas |
intercepts of a |
betas |
shift terms of a |
The warmstarted model has to be assigned to a new variable.
library(tram)
set.seed(2021)
data(wine, package = "ordinal")
wine$noise <- rnorm(nrow(wine))
y <- model.matrix(~ 0 + rating, data = wine)
x <- ontram:::.rm_int(model.matrix(rating ~ temp + contact, data = wine))
im <- ontram:::.rm_int(model.matrix(rating ~ noise, data = wine))
loss <- k_ontram_loss(ncol(y))
mod_polr <- Polr(rating ~ temp + contact, data = wine)
msh <- mod_shift(ncol(x))
mbl <- keras_model_sequential() %>%
layer_dense(units = 8, input_shape = 1L, activation = "relu") %>%
layer_dense(units = 16, activation = "relu") %>%
layer_dense(units = ncol(y) - 1, use_bias = FALSE) %>%
layer_trafo_intercept()()
mo <- k_ontram(mbl, msh, complex_intercept = TRUE)
mo <- warmstart(mo, thetas = coef(mod_polr, with_baseline = TRUE)[1:4L],
betas = coef(mod_polr), which = "all")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.