pipeop_preproc_torch {mlr3torch}R Documentation

Create Torch Preprocessing PipeOps

Description

Function to create objects of class PipeOpTaskPreprocTorch in a more convenient way. Start by reading the documentation of PipeOpTaskPreprocTorch.

Usage

pipeop_preproc_torch(
  id,
  fn,
  shapes_out = NULL,
  param_set = NULL,
  packages = character(0),
  rowwise = FALSE,
  parent_env = parent.frame(),
  stages_init = NULL,
  tags = NULL
)

Arguments

id

(character(1))
The id for of the new object.

fn

(function)
The preprocessing function.

shapes_out

(function or NULL or "infer")
The private .shapes_out(shapes_in, param_vals, task) method of PipeOpTaskPreprocTorch (see section Inheriting). Special values are NULL and infer: If NULL, the output shapes are unknown. If "infer", the output shape function is inferred and calculates the output shapes as follows: For an input shape of (NA, ...) a meta-tensor of shape (1, ...) is created and the preprocessing function is applied. Afterwards the batch dimension (1) is replaced with NA and the shape is returned. If the first dimension is not NA, the output shape of applying the preprocessing function is returned. Method "infer" should be correct in most cases, but might fail in some edge cases.

param_set

(ParamSet or NULL)
The parameter set. If this is left as NULL (default) the parameter set is inferred in the following way: All parameters but the first and ... of fn are set as untyped parameters with tags 'train' and those that have no default value are tagged as 'required' as well. Default values are not annotated.

packages

(character())
The R packages this object depends on.

rowwise

(logical(1))
Whether the preprocessing is applied row-wise.

parent_env

(environment)
The parent environment for the R6 class.

stages_init

(character(1))
Initial value for the stages parameter. If NULL (default), will be set to "both" in case the id starts with "trafo" and to "train" if it starts with "augment". Otherwise it must specified.

tags

(character())
Tags for the pipeop

Value

An R6Class instance inheriting from PipeOpTaskPreprocTorch

Examples


PipeOpPreprocExample = pipeop_preproc_torch("preproc_example", function(x, a) x + a)
po_example = PipeOpPreprocExample$new()
po_example$param_set


[Package mlr3torch version 0.1.0 Index]