warmstart.ontram_rv | R Documentation |
Set initial weights
## S3 method for class 'ontram_rv'
warmstart(object, object_w, which = c("all", "baseline only", "shift only"))
object |
an object of class |
object_w |
an object of class |
library(tram)
set.seed(2021)
data("wine", package = "ordinal")
wine$noise <- rnorm(nrow(wine), sd = 0.3) + as.numeric(wine$rating)
fml <- rating ~ temp + contact
x_train <- model.matrix(fml, data = wine)[, -1L, drop = FALSE]
y_train <- model.matrix(~ 0 + rating, data = wine)
im_train <- model.matrix(rating ~ noise, data = wine)[, -1L, drop = FALSE]
mp <- Polr(fml, data = wine)
mbl1 <- keras_model_sequential() %>%
layer_dense(units = 4, input_shape = 1L, activation = "tanh") %>%
layer_dense(ncol(y_train) - 1)
msh1 <- mod_shift(ncol(x_train))
mo_rv1 <- ontram(mod_bl = mbl1, mod_sh = msh1, method = "logit",
x_dim = ncol(x_train), y_dim = ncol(y_train),
response_varying = TRUE)
fit_ontram(mo_rv1, x_train = x_train, y_train = y_train, img_train = im_train)
mbl2 <- keras_model_sequential() %>%
layer_dense(units = 4, input_shape = 1L, activation = "tanh") %>%
layer_dense(ncol(y_train) - 1)
msh2 <- mod_shift(ncol(x_train))
mo_rv2 <- ontram(mod_bl = mbl2, mod_sh = msh2, method = "logit",
x_dim = ncol(x_train), y_dim = ncol(y_train),
response_varying = TRUE)
mod_weights(mo_rv2)
warmstart(mo_rv2, mo_rv1, "baseline only")
mod_weights(mo_rv2)
coef(mp)
warmstart(mo_rv2, mp, "shift only")
mod_weights(mo_rv2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.