as_task_torch: Create a Generic Torch Task

View source: R/TaskTorch.R

as_task_torchR Documentation

Create a Generic Torch Task

Description

Creates a TaskTorch, the general-purpose task type of mlr3torch, from a data.frame() or a DataBackend. See the Custom Learning Problems article for more information.

Usage

as_task_torch(x, target = NULL, id = deparse(substitute(x))[1L], ...)

Arguments

x

(data.frame() or DataBackend)
The data.

target

(character() or NULL)
The names of the target columns. NULL (default) for a task without a target, see section Tasks without a Target of TaskTorch.

id

(character(1))
The id of the task.

...

(any)
Further arguments passed to TaskTorch⁠$new()⁠, such as output_dim, default_encoder, default_target_batchgetter or default_measure.

Value

TaskTorch

Examples


# multi-output regression
d = data.frame(x = rnorm(50))
d$y1 = d$x + rnorm(50)
d$y2 = 2 * d$x + rnorm(50)
as_task_torch(d, target = c("y1", "y2"))

# unsupervised: no target at all
as_task_torch(data.frame(a = rnorm(50), b = rnorm(50)))


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