GraphLearnerTorch: Graph Learner for Torch Networks

GraphLearnerTorchR Documentation

Graph Learner for Torch Networks

Description

The GraphLearner that as_learner_torch() returns. On top of a GraphLearner it has the ⁠$network⁠, ⁠$loss⁠, ⁠$optimizer⁠ and ⁠$callbacks⁠ fields and the ⁠$dataset()⁠ method of a LearnerTorch. If the graph contains a PipeOpTorchModel, the loss, optimizer and callbacks are those of its configuring operators, otherwise those of its base LearnerTorch. It is not in the mlr_learners dictionary, because it cannot be constructed without a graph.

Super classes

mlr3::Learner -> mlr3pipelines::GraphLearner -> GraphLearnerTorch

Active bindings

network

(nn_module)
The network of the trained learner, i.e. ⁠$base_learner()$network⁠.

loss

(TorchLoss)
The torch loss, i.e. the one of the graph's PipeOpTorchLoss or of its base LearnerTorch. Read-only, the graph configures it.

optimizer

(TorchOptimizer)
The torch optimizer, i.e. the one of the graph's PipeOpTorchOptimizer or of its base LearnerTorch. Read-only, the graph configures it.

callbacks

(list() of TorchCallbacks)
The callbacks, i.e. those of the graph's PipeOpTorchCallbacks or of its base LearnerTorch. Read-only, the graph configures them.

Methods

Public methods

Inherited methods

GraphLearnerTorch$dataset()

Create the dataset for a task, i.e. the tensors that are fed to the network.

Usage
GraphLearnerTorch$dataset(
  task,
  stage = if (is.null(self$model)) "train" else "predict"
)
Arguments
task

Task
The task.

stage

(character(1))
Whether to create the dataset the way ⁠$train()⁠ does ("train") or the way ⁠$predict()⁠ does ("predict"). Defaults to "predict" for a trained learner and to "train" otherwise, because the prediction phase reuses the state that the operators before the ingress fitted during training.

Returns

dataset


GraphLearnerTorch$clone()

The objects of this class are cloneable with this method.

Usage
GraphLearnerTorch$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

Other Learner: as_learner_torch(), mlr_learners.ft_transformer, mlr_learners.mlp, mlr_learners.module, mlr_learners.realmlp, mlr_learners.tab_resnet, mlr_learners.tabm, mlr_learners.torch_featureless, mlr_learners_torch, mlr_learners_torch_image, mlr_learners_torch_model


mlr3torch documentation built on Oct. 30, 2026, 5:10 p.m.