Create a Learner for collaborative filtering on `dls`.
collab_learner(
dls,
n_factors = 50,
use_nn = FALSE,
emb_szs = NULL,
layers = NULL,
config = NULL,
y_range = NULL,
loss_func = NULL,
opt_func = Adam(),
lr = 0.001,
splitter = trainable_params(),
cbs = NULL,
metrics = NULL,
path = NULL,
model_dir = "models",
wd = NULL,
wd_bn_bias = FALSE,
train_bn = TRUE,
moms = list(0.95, 0.85, 0.95)
)
a data loader object
The number of factors
use_nn
embedding size
list of layers
configuration
y_range
It can be any loss function you like. It needs to be one of fastai's if you want to use Learn.predict or Learn.get_preds, or you will have to implement special methods (see more details after the BaseLoss documentation).
The function used to create the optimizer
learning rate
It is a function that takes self.model and returns a list of parameter groups (or just one parameter group if there are no different parameter groups).
Cbs is one or a list of Callbacks to pass to the Learner.
It is an optional list of metrics, that can be either functions or Metrics.
The folder where to work
Path and model_dir are used to save and/or load models.
It is the default weight decay used when training the model.
It controls if weight decay is applied to BatchNorm layers and bias.
It controls if BatchNorm layers are trained even when they are supposed to be frozen according to the splitter.
The default momentums used in Learner.fit_one_cycle.
learner object
if (FALSE) {
URLs_MOVIE_LENS_ML_100k()
c(user,item,title) %<-% list('userId','movieId','title')
ratings = fread('ml-100k/u.data', col.names = c(user,item,'rating','timestamp'))
movies = fread('ml-100k/u.item', col.names = c(item, 'title', 'date', 'N', 'url',
paste('g',1:19,sep = '')))
rating_movie = ratings[movies[, .SD, .SDcols=c(item,title)], on = item]
dls = CollabDataLoaders_from_df(rating_movie, seed = 42, valid_pct = 0.1, bs = 64,
item_name=title, path='ml-100k')
learn = collab_learner(dls, n_factors = 40, y_range=c(0, 5.5))
learn %>% fit_one_cycle(1, 5e-3, wd = 1e-1)
}