View source: R/k-ontram_methods.R
warmstart.k_ontram | R Documentation |
Set initial weights
## S3 method for class 'k_ontram'
warmstart(
object,
thetas = NULL,
betas = NULL,
which = c("all", "baseline only", "shift only")
)
object |
an object of class |
thetas |
intercepts of a |
betas |
shift terms of a |
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)
mbl <- k_mod_baseline(ncol(y))
msh <- mod_shift(ncol(x))
mim <- keras_model_sequential() %>%
layer_dense(units = 8, input_shape = 1L, activation = "relu") %>%
layer_dense(units = 16, activation = "relu") %>%
layer_dense(units = 1, use_bias = FALSE)
mo <- k_ontram(mbl, list(msh, mim))
mo <- warmstart(mo, thetas = coef(mod_polr, with_baseline = T)[1:4L],
which = "baseline only")
coef(mod_polr, with_baseline = TRUE)
ontram:::.to_theta(get_weights(mo$mod_baseline)[[1]])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.