Create a torch learner from an instantiated nn_module(). For classification, the output of the network must be the scores (before the softmax).
Parameters
See LearnerTorch
Examples
# We show the learner using a classification task# The iris task has 4 features and 3 classesnetwork = nn_linear(4,3)task = tsk("iris")# This defines the dataloader.# It loads all 4 features, which are also numeric.# The shape is (NA, 4) because the batch dimension is generally NAingress_tokens = list( input = TorchIngressToken(task$feature_names, batchgetter_num, c(NA,4)))# Creating the learner and setting required parameterslearner = lrn("classif.torch_model", network = network, ingress_tokens = ingress_tokens, batch_size =16, epochs =1, device ="cpu")# A simple train-predictids = partition(task)learner$train(task, ids$train)learner$predict(task, ids$test)
See Also
Other Learner: mlr_learners.mlp, mlr_learners.tab_resnet, mlr_learners.torch_featureless, mlr_learners_torch, mlr_learners_torch_image