| Title: | Deep Learning with 'mlr3' |
| Version: | 0.3.2 |
| Description: | Deep Learning library that extends the mlr3 framework by building upon the 'torch' package. It allows to conveniently build, train, and evaluate deep learning models without having to worry about low level details. Custom architectures can be created using the graph language defined in 'mlr3pipelines'. |
| License: | LGPL (≥ 3) |
| BugReports: | https://github.com/mlr-org/mlr3torch/issues |
| URL: | https://mlr3torch.mlr-org.com/,https://github.com/mlr-org/mlr3torch/ |
| Depends: | mlr3 (≥ 1.0.1), mlr3pipelines (≥ 0.6.0), torch (≥ 0.16.2),R (≥ 3.5.0) |
| Imports: | backports, cli, checkmate (≥ 2.2.0), data.table, lgr,methods, mlr3misc (≥ 0.14.0), paradox (≥ 1.0.0), R6, withr |
| Suggests: | callr, curl, future, ggplot2, igraph, jsonlite, knitr,mlr3tuning (≥ 1.0.0), progress, rmarkdown, rpart, viridis,visNetwork, testthat (≥ 3.0.0), tibble, tfevents, torchvision(≥ 0.6.0), waldo |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | no |
| ByteCompile: | yes |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.2.9000 |
| Collate: | 'CallbackSet.R' 'aaa.R' 'TorchCallback.R''CallbackSetCheckpoint.R' 'CallbackSetEarlyStopping.R''CallbackSetHistory.R' 'CallbackSetLRScheduler.R''CallbackSetProgress.R' 'CallbackSetTB.R''CallbackSetUnfreeze.R' 'ContextTorch.R' 'DataBackendLazy.R''utils.R' 'DataDescriptor.R' 'LearnerFTTransformer.R''LearnerTorch.R' 'LearnerTorchFeatureless.R''LearnerTorchImage.R' 'LearnerTorchMLP.R' 'task_dataset.R''shape.R' 'PipeOpTorchIngress.R' 'LearnerTorchModel.R''LearnerTorchModule.R' 'LearnerTorchTabResNet.R''LearnerTorchVision.R' 'ModelDescriptor.R' 'PipeOpModule.R''PipeOpTorch.R' 'PipeOpTaskPreprocTorch.R''PipeOpTorchActivation.R' 'PipeOpTorchAdaptiveAvgPool.R''PipeOpTorchAvgPool.R' 'PipeOpTorchBatchNorm.R''PipeOpTorchBlock.R' 'PipeOpTorchCallbacks.R''PipeOpTorchConv.R' 'PipeOpTorchConvTranspose.R''PipeOpTorchDropout.R' 'PipeOpTorchFTCLS.R''PipeOpTorchFTTransformerBlock.R' 'PipeOpTorchFn.R''PipeOpTorchHead.R' 'PipeOpTorchIdentity.R''PipeOpTorchLayerNorm.R' 'PipeOpTorchLinear.R' 'TorchLoss.R''PipeOpTorchLoss.R' 'PipeOpTorchMaxPool.R' 'PipeOpTorchMerge.R''PipeOpTorchModel.R' 'PipeOpTorchOptimizer.R''PipeOpTorchReshape.R' 'PipeOpTorchSoftmax.R''PipeOpTorchTokenizer.R' 'Select.R' 'TaskClassif_cifar.R''TaskClassif_lazy_iris.R' 'TaskClassif_melanoma.R''TaskClassif_mnist.R' 'TaskClassif_tiny_imagenet.R''TorchDescriptor.R' 'TorchOptimizer.R' 'bibentries.R' 'cache.R''lazy_tensor.R' 'learner_torch_methods.R' 'materialize.R''merge_graphs.R' 'multi_tensor_dataset.R' 'nn.R' 'nn_graph.R''paramset_torchlearner.R' 'preprocess.R' 'rd_info.R''with_torch_settings.R' 'zzz.R' |
| Packaged: | 2025-10-31 08:39:34 UTC; sebi |
| Author: | Sebastian Fischer |
| Maintainer: | Sebastian Fischer <sebf.fischer@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2025-10-31 09:10:08 UTC |
mlr3torch: Deep Learning with 'mlr3'
Description
Deep Learning library that extends the mlr3 framework by building upon the 'torch' package. It allows to conveniently build, train, and evaluate deep learning models without having to worry about low level details. Custom architectures can be created using the graph language defined in 'mlr3pipelines'.
Options
mlr3torch.cache:Whether to cache the downloaded data (TRUE) or not (FALSE, default).This can also be set to a specific folder on the file system to be used as the cache directory.
Author(s)
Maintainer: Sebastian Fischersebf.fischer@gmail.com (ORCID)
Authors:
Martin Bindermlr.developer@mb706.com
Other contributors:
Bernd Bischlbernd_bischl@gmx.net (ORCID) [contributor]
Lukas Burkgithub@quantenbrot.de (ORCID) [contributor]
Florian Pfistererpfistererf@googlemail.com (ORCID) [contributor]
Carson Zhangcarsonzhang4@gmail.com [contributor]
See Also
Useful links:
Report bugs athttps://github.com/mlr-org/mlr3torch/issues
Compare lazy tensors
Description
Compares lazy tensors using their indices and the data descriptor's hash.This means that if twolazy_tensors:
are equal: they will mateterialize to the same tensors.
are unequal: they might materialize to the same tensors.
Usage
## S3 method for class 'lazy_tensor'x == yArguments
x,y | ( |
Data Descriptor
Description
A data descriptor is a rather internal data structure used in thelazy_tensor data type.In essence it is an annotatedtorch::dataset and a preprocessing graph (consisting mosty ofPipeOpModuleoperators). The additional meta data (e.g. pointer, shapes) allows to preprocesslazy_tensors in anmlr3pipelines::Graph just like any (non-lazy) data types.The preprocessing is applied whenmaterialize() is called on thelazy_tensor.
To create a data descriptor, you can also use theas_data_descriptor() function.
Details
While it would be more natural to define this as an S3 class, we opted for an R6 class to avoid the usualtrouble of serializing S3 objects.If each row contained a DataDescriptor as an S3 class, this would copy the object when serializing.
Public fields
dataset(
torch::dataset)
The dataset.graph(
Graph)
The preprocessing graph.dataset_shapes(named
list()of (integer()orNULL))
The shapes of the output.input_map(
character())
The input map from the dataset to the preprocessing graph.pointer(
character(2))
The output pointer.pointer_shape(
integer()|NULL)
The shape of the output indicated bypointer.dataset_hash(
character(1))
Hash for the wrapped dataset.hash(
character(1))
Hash for the data descriptor.graph_input(
character())
The input channels of the preprocessing graph (cached to save time).pointer_shape_predict(
integer()orNULL)
Internal use only.
Methods
Public methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
DataDescriptor$new( dataset, dataset_shapes = NULL, graph = NULL, input_map = NULL, pointer = NULL, pointer_shape = NULL, pointer_shape_predict = NULL, clone_graph = TRUE)
Arguments
dataset(
torch::dataset)
The torch dataset.It should return a namedlist()oftorch_tensorobjects.dataset_shapes(named
list()of (integer()orNULL))
The shapes of the output.Names are the elements of the list returned by the dataset.If the shape is notNULL(unknown, e.g. for images of different sizes) the first dimension must beNAtoindicate the batch dimension.graph(
Graph)
The preprocessing graph.If leftNULL, no preprocessing is applied to the data andinput_map,pointer,pointer_shape, andpointer_shape_predictare inferred in case the dataset returns only one element.input_map(
character())
Character vector that must have the same length as the input of the graph.Specifies how the data from thedatasetis fed into the preprocessing graph.pointer(
character(2)|NULL)
Points to an output channel withingraph:Element 1 is thePipeOp's id and element 2 is thatPipeOp's output channel.pointer_shape(
integer()|NULL)
Shape of the output indicated bypointer.pointer_shape_predict(
integer()orNULL)
Internal use only.Used in aGraphto anticipate possible mismatches between train and predict shapes.clone_graph(
logical(1))
Whether to clone the preprocessing graph.
Methodprint()
Prints the object
Usage
DataDescriptor$print(...)
Arguments
...(any)
Unused
Methodclone()
The objects of this class are cloneable with this method.
Usage
DataDescriptor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
ModelDescriptor, lazy_tensor
Examples
# Create a datasetds = dataset( initialize = function() self$x = torch_randn(10, 3, 3), .getitem = function(i) list(x = self$x[i, ]), .length = function() nrow(self$x))()dd = DataDescriptor$new(ds, list(x = c(NA, 3, 3)))dd# is the same as using the converter:as_data_descriptor(ds, list(x = c(NA, 3, 3)))Represent a Model with Meta-Info
Description
Represents amodel; possibly a complete model, possibly one in the process of being built up.
This model takes input tensors of shapesshapes_in andpipes them throughgraph. Input shapes get mapped to input channels ofgraph.Output shapes are named by the output channels ofgraph; it is also possibleto represent no-ops on tensors, in which case names of input and output should be identical.
ModelDescriptor objects typically represent partial models being built up, in which case thepointer slotindicates a specific point in the graph that produces a tensor of shapepointer_shape, on which the graph shouldbe extended.It is allowed for thegraph in this structure to be modified by-reference in different parts of the code.However, these modifications may never add edges with elements of theGraph as destination. In particular, noelement ofgraph$input may be removed by reference, e.g. by adding an edge to theGraph that has the inputchannel of aPipeOp that was previously without parent as its destination.
In most cases it is better to create a specificModelDescriptor by training aGraph consisting (mostly) ofoperatorsPipeOpTorchIngress,PipeOpTorch,PipeOpTorchLoss,PipeOpTorchOptimizer, andPipeOpTorchCallbacks.
AModelDescriptor can be converted to ann_graph viamodel_descriptor_to_module.
Usage
ModelDescriptor( graph, ingress, task, optimizer = NULL, loss = NULL, callbacks = NULL, pointer = NULL, pointer_shape = NULL)Arguments
graph | ( |
ingress | (uniquely named |
task | ( |
optimizer | ( |
loss | ( |
callbacks | (A |
pointer | ( |
pointer_shape | ( |
Value
(ModelDescriptor)
See Also
Other Model Configuration:mlr_pipeops_torch_callbacks,mlr_pipeops_torch_loss,mlr_pipeops_torch_optimizer,model_descriptor_union()
Other Graph Network:TorchIngressToken(),mlr_learners_torch_model,mlr_pipeops_module,mlr_pipeops_torch,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,model_descriptor_to_learner(),model_descriptor_to_module(),model_descriptor_union(),nn_graph()
Selector Functions for Character Vectors
Description
ASelect function subsets a character vector. They are used by the callbackCallbackSetUnfreeze to select parameters to freeze or unfreeze during training.
Usage
select_all()select_none()select_grep(pattern, ignore.case = FALSE, perl = FALSE, fixed = FALSE)select_name(param_names, assert_present = TRUE)select_invert(select)Arguments
pattern | See |
ignore.case | See |
perl | See |
fixed | See |
param_names | The names of the parameters that you want to select |
assert_present | Whether to check that |
select | A |
Functions
select_all():select_allselects all elementsselect_none():select_noneselects no elementsselect_grep():select_grepselects elements with names matching a regular expressionselect_name():select_nameselects elements with names matching the given namesselect_invert():select_invertselects the elements NOT selected by the given selector
Examples
select_all()(c("a", "b"))select_none()(c("a", "b"))select_grep("b$")(c("ab", "ac"))select_name("a")(c("a", "b"))select_invert(select_all())(c("a", "b"))Torch Callback
Description
This wraps aCallbackSet and annotates it with metadata, most importantly aParamSet.The callback is created for the given parameter values by calling the$generate() method.
This class is usually used to configure the callback of a torch learner, e.g. when constructinga learner of in aModelDescriptor.
For a list of available callbacks, seemlr3torch_callbacks.To conveniently retrieve aTorchCallback, uset_clbk().
Parameters
Defined by the constructor argumentparam_set.If no parameter set is provided during construction, the parameter set is constructed by creating a parameterfor each argument of the wrapped loss function, where the parametes are then of typeParamUty.
Super class
mlr3torch::TorchDescriptor ->TorchCallback
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
TorchCallback$new( callback_generator, param_set = NULL, id = NULL, label = NULL, packages = NULL, man = NULL, additional_args = NULL)
Arguments
callback_generator(
R6ClassGenerator)
The class generator for the callback that is being wrapped.param_set(
ParamSetorNULL)
The parameter set. IfNULL(default) it is inferred fromcallback_generator.id(
character(1))
The id for of the new object.label(
character(1))
Label for the new instance.packages(
character())
The R packages this object depends on.man(
character(1))
String in the format[pkg]::[topic]pointing to a manual page for this object.The referenced help package can be opened via method$help().additional_args(
any)
Additional arguments if necessary. For learning rate schedulers, this is the torch::LRScheduler.
Methodclone()
The objects of this class are cloneable with this method.
Usage
TorchCallback$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Callback:as_torch_callback(),as_torch_callbacks(),callback_set(),mlr3torch_callbacks,mlr_callback_set,mlr_callback_set.checkpoint,mlr_callback_set.progress,mlr_callback_set.tb,mlr_callback_set.unfreeze,mlr_context_torch,t_clbk(),torch_callback()
Other Torch Descriptor:TorchDescriptor,TorchLoss,TorchOptimizer,as_torch_callbacks(),as_torch_loss(),as_torch_optimizer(),mlr3torch_losses,mlr3torch_optimizers,t_clbk(),t_loss(),t_opt()
Examples
# Create a new torch callback from an existing callback settorch_callback = TorchCallback$new(CallbackSetCheckpoint)# The parameters are inferredtorch_callback$param_set# Retrieve a torch callback from the dictionarytorch_callback = t_clbk("checkpoint", path = tempfile(), freq = 1)torch_callbacktorch_callback$labeltorch_callback$id# open the help page of the wrapped callback set# torch_callback$help()# Create the callback setcallback = torch_callback$generate()callback# is the same asCallbackSetCheckpoint$new( path = tempfile(), freq = 1)# Use in a learnerlearner = lrn("regr.mlp", callbacks = t_clbk("checkpoint"))# the parameters of the callback are added to the learner's parameter setlearner$param_setBase Class for Torch Descriptors
Description
Abstract Base Class from whichTorchLoss,TorchOptimizer, andTorchCallback inherit.This class wraps a generator (R6Class Generator or the torch version of such a generator) and annotates itwith metadata such as aParamSet, a label, an ID, packages, or a manual page.
The parameters are the construction arguments of the wrapped generator and the parameter$values are passedto the generator when calling the public method$generate().
Parameters
Defined by the constructor argumentparam_set.All parameters are tagged with"train", but this is done automatically during initialize.
Public fields
label(
character(1))
Label for this object.Can be used in tables, plot and text output instead of the ID.param_set(
ParamSet)
Set of hyperparameters.packages(
character(1))
Set of required packages.These packages are loaded, but not attached.id(
character(1))
Identifier of the object.Used in tables, plot and text output.generatorThe wrapped generator that is described.
man(
character(1))
String in the format[pkg]::[topic]pointing to a manual page for this object.
Active bindings
phash(
character(1))
Hash (unique identifier) for this partial object, excluding some componentswhich are varied systematically (e.g. the parameter values).
Methods
Public methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
TorchDescriptor$new( generator, id = NULL, param_set = NULL, packages = NULL, label = NULL, man = NULL, additional_args = NULL)
Arguments
generatorThe wrapped generator that is described.
id(
character(1))
The id for of the new object.param_set(
ParamSet)
The parameter set.packages(
character())
The R packages this object depends on.label(
character(1))
Label for the new instance.man(
character(1))
String in the format[pkg]::[topic]pointing to a manual page for this object.The referenced help package can be opened via method$help().additional_args(
list())
Additional arguments if necessary. For learning rate schedulers, this is the torch::LRScheduler.
Methodprint()
Prints the object
Usage
TorchDescriptor$print(...)
Arguments
...any
Methodgenerate()
Calls the generator with the given parameter values.
Usage
TorchDescriptor$generate()
Methodhelp()
Displays the help file of the wrapped object.
Usage
TorchDescriptor$help()
Methodclone()
The objects of this class are cloneable with this method.
Usage
TorchDescriptor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Torch Descriptor:TorchCallback,TorchLoss,TorchOptimizer,as_torch_callbacks(),as_torch_loss(),as_torch_optimizer(),mlr3torch_losses,mlr3torch_optimizers,t_clbk(),t_loss(),t_opt()
Torch Ingress Token
Description
This function creates an S3 class of class"TorchIngressToken", which is an internal data structure.It contains the (meta-)information of how a batch is generated from aTask and fed into an entry pointof the neural network. It is stored as theingress field in aModelDescriptor.
Usage
TorchIngressToken(features, batchgetter, shape = NULL)Arguments
features | ( |
batchgetter | ( |
shape | ( |
Value
TorchIngressToken object.
See Also
Other Graph Network:ModelDescriptor(),mlr_learners_torch_model,mlr_pipeops_module,mlr_pipeops_torch,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,model_descriptor_to_learner(),model_descriptor_to_module(),model_descriptor_union(),nn_graph()
Examples
# Define a task for which we want to define an ingress tokentask = tsk("iris")# We create an ingress token for two feature Sepal.Length and Petal.Length:# We have to specify the features, the batchgetter and the shapefeatures = c("Sepal.Length", "Petal.Length")# As a batchgetter we use batchgetter_numbatch_dt = task$data(rows = 1:10, cols =features)batch_dtbatch_tensor = batchgetter_num(batch_dt, "cpu")batch_tensor# The shape is unknown in the first dimension (batch dimension)ingress_token = TorchIngressToken( features = features, batchgetter = batchgetter_num, shape = c(NA, 2))ingress_tokenTorch Loss
Description
This wraps atorch::nn_loss and annotates it with metadata, most importantly aParamSet.The loss function is created for the given parameter values by calling the$generate() method.
This class is usually used to configure the loss function of a torch learner, e.g.when construcing a learner or in aModelDescriptor.
For a list of available losses, seemlr3torch_losses.Items from this dictionary can be retrieved usingt_loss().
Parameters
Defined by the constructor argumentparam_set.If no parameter set is provided during construction, the parameter set is constructed by creating a parameterfor each argument of the wrapped loss function, where the parametes are then of typeParamUty.
Super class
mlr3torch::TorchDescriptor ->TorchLoss
Public fields
task_types(
character())
The task types this loss supports.
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
TorchLoss$new( torch_loss, task_types = NULL, param_set = NULL, id = NULL, label = NULL, packages = NULL, man = NULL)
Arguments
torch_loss(
nn_lossorfunction)
The loss module or function that generates the loss module.Can have argumentstaskthat will be provided when the loss is instantiated.task_types(
character())
The task types supported by this loss.param_set(
ParamSetorNULL)
The parameter set. IfNULL(default) it is inferred fromtorch_loss.id(
character(1))
The id for of the new object.label(
character(1))
Label for the new instance.packages(
character())
The R packages this object depends on.man(
character(1))
String in the format[pkg]::[topic]pointing to a manual page for this object.The referenced help package can be opened via method$help().
Methodprint()
Prints the object
Usage
TorchLoss$print(...)
Arguments
...any
Methodgenerate()
Instantiates the loss function.
Usage
TorchLoss$generate(task = NULL)
Arguments
task(
Task)
The task. Must be provided if the loss function requires a task.
Returns
torch_loss
Methodclone()
The objects of this class are cloneable with this method.
Usage
TorchLoss$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Torch Descriptor:TorchCallback,TorchDescriptor,TorchOptimizer,as_torch_callbacks(),as_torch_loss(),as_torch_optimizer(),mlr3torch_losses,mlr3torch_optimizers,t_clbk(),t_loss(),t_opt()
Examples
# Create a new torch losstorch_loss = TorchLoss$new(torch_loss = nn_mse_loss, task_types = "regr")torch_loss# the parameters are inferredtorch_loss$param_set# Retrieve a loss from the dictionary:torch_loss = t_loss("mse", reduction = "mean")# is the same astorch_losstorch_loss$param_settorch_loss$labeltorch_loss$task_typestorch_loss$id# Create the loss functionloss_fn = torch_loss$generate()loss_fn# Is the same asnn_mse_loss(reduction = "mean")# open the help page of the wrapped loss function# torch_loss$help()# Use in a learnerlearner = lrn("regr.mlp", loss = t_loss("mse"))# The parameters of the loss are added to the learner's parameter setlearner$param_setTorch Optimizer
Description
This wraps atorch::torch_optimizer_generator and annotates it with metadata, most importantly aParamSet.The optimizer is created for the given parameter values by calling the$generate() method.
This class is usually used to configure the optimizer of a torch learner, e.g.when constructing a learner or in aModelDescriptor.
For a list of available optimizers, seemlr3torch_optimizers.Items from this dictionary can be retrieved usingt_opt().
Parameters
Defined by the constructor argumentparam_set.If no parameter set is provided during construction, the parameter set is constructed by creating a parameterfor each argument of the wrapped loss function, where the parameters are then of typeParamUty.
Super class
mlr3torch::TorchDescriptor ->TorchOptimizer
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
TorchOptimizer$new( torch_optimizer, param_set = NULL, id = NULL, label = NULL, packages = NULL, man = NULL)
Arguments
torch_optimizer(
torch_optimizer_generator)
The torch optimizer.param_set(
ParamSetorNULL)
The parameter set. IfNULL(default) it is inferred fromtorch_optimizer.id(
character(1))
The id for of the new object.label(
character(1))
Label for the new instance.packages(
character())
The R packages this object depends on.man(
character(1))
String in the format[pkg]::[topic]pointing to a manual page for this object.The referenced help package can be opened via method$help().
Methodgenerate()
Instantiates the optimizer.
Usage
TorchOptimizer$generate(params)
Arguments
params(named
list()oftorch_tensors)
The parameters of the network.
Returns
torch_optimizer
Methodclone()
The objects of this class are cloneable with this method.
Usage
TorchOptimizer$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Torch Descriptor:TorchCallback,TorchDescriptor,TorchLoss,as_torch_callbacks(),as_torch_loss(),as_torch_optimizer(),mlr3torch_losses,mlr3torch_optimizers,t_clbk(),t_loss(),t_opt()
Examples
# Create a new torch optimizertorch_opt = TorchOptimizer$new(optim_ignite_adam, label = "adam")torch_opt# If the param set is not specified, parameters are inferred but are of class ParamUtytorch_opt$param_set# open the help page of the wrapped optimizer# torch_opt$help()# Retrieve an optimizer from the dictionarytorch_opt = t_opt("sgd", lr = 0.1)torch_opttorch_opt$param_settorch_opt$labeltorch_opt$id# Create the optimizer for a networknet = nn_linear(10, 1)opt = torch_opt$generate(net$parameters)# is the same asoptim_sgd(net$parameters, lr = 0.1)# Use in a learnerlearner = lrn("regr.mlp", optimizer = t_opt("sgd"))# The parameters of the optimizer are added to the learner's parameter setlearner$param_setConvert to Data Descriptor
Description
Converts the input to aDataDescriptor.
Usage
as_data_descriptor(x, dataset_shapes, ...)Arguments
x | (any) |
dataset_shapes | (named |
... | (any) |
Examples
ds = dataset("example", initialize = function() self$iris = iris[, -5], .getitem = function(i) list(x = torch_tensor(as.numeric(self$iris[i, ]))), .length = function() nrow(self$iris))()as_data_descriptor(ds, list(x = c(NA, 4L)))# if the dataset has a .getbatch method, the shapes are inferredds2 = dataset("example", initialize = function() self$iris = iris[, -5], .getbatch = function(i) list(x = torch_tensor(as.matrix(self$iris[i, ]))), .length = function() nrow(self$iris))()as_data_descriptor(ds2)Convert to Lazy Tensor
Description
Convert a object to alazy_tensor.
Usage
as_lazy_tensor(x, ...)## S3 method for class 'dataset'as_lazy_tensor(x, dataset_shapes = NULL, ids = NULL, ...)Arguments
x | (any) |
... | (any) |
dataset_shapes | (named |
ids | ( |
Examples
iris_ds = dataset("iris", initialize = function() { self$iris = iris[, -5] }, .getbatch = function(i) { list(x = torch_tensor(as.matrix(self$iris[i, ]))) }, .length = function() nrow(self$iris))()# no need to specify the dataset shapes as they can be inferred from the .getbatch method# only first 5 observationsas_lazy_tensor(iris_ds, ids = 1:5)# all observationshead(as_lazy_tensor(iris_ds))iris_ds2 = dataset("iris", initialize = function() self$iris = iris[, -5], .getitem = function(i) list(x = torch_tensor(as.numeric(self$iris[i, ]))), .length = function() nrow(self$iris))()# if .getitem is implemented we cannot infer the shapes as they might vary,# so we have to annotate them explicitlyas_lazy_tensor(iris_ds2, dataset_shapes = list(x = c(NA, 4L)))[1:5]# Convert a matrixlt = as_lazy_tensor(matrix(rnorm(100), nrow = 20))materialize(lt[1:5], rbind = TRUE)Convert to CallbackSetLRScheduler
Description
Convert atorch scheduler generator to aCallbackSetLRScheduler.
Usage
as_lr_scheduler(x, step_on_epoch)Arguments
x | ( |
step_on_epoch | ( |
Convert to a TorchCallback
Description
Converts an object to aTorchCallback.
Usage
as_torch_callback(x, clone = FALSE, ...)Arguments
x | (any) |
clone | ( |
... | (any) |
Value
See Also
Other Callback:TorchCallback,as_torch_callbacks(),callback_set(),mlr3torch_callbacks,mlr_callback_set,mlr_callback_set.checkpoint,mlr_callback_set.progress,mlr_callback_set.tb,mlr_callback_set.unfreeze,mlr_context_torch,t_clbk(),torch_callback()
Convert to a list of Torch Callbacks
Description
Converts an object to a list ofTorchCallback.
Usage
as_torch_callbacks(x, clone, ...)Arguments
x | (any) |
clone | ( |
... | (any) |
Value
list() ofTorchCallbacks
See Also
Other Callback:TorchCallback,as_torch_callback(),callback_set(),mlr3torch_callbacks,mlr_callback_set,mlr_callback_set.checkpoint,mlr_callback_set.progress,mlr_callback_set.tb,mlr_callback_set.unfreeze,mlr_context_torch,t_clbk(),torch_callback()
Other Torch Descriptor:TorchCallback,TorchDescriptor,TorchLoss,TorchOptimizer,as_torch_loss(),as_torch_optimizer(),mlr3torch_losses,mlr3torch_optimizers,t_clbk(),t_loss(),t_opt()
Convert to TorchLoss
Description
Converts an object to aTorchLoss.
Usage
as_torch_loss(x, clone = FALSE, ...)Arguments
x | (any) |
clone | ( |
... | (any) |
Value
See Also
Other Torch Descriptor:TorchCallback,TorchDescriptor,TorchLoss,TorchOptimizer,as_torch_callbacks(),as_torch_optimizer(),mlr3torch_losses,mlr3torch_optimizers,t_clbk(),t_loss(),t_opt()
Convert to TorchOptimizer
Description
Converts an object to aTorchOptimizer.
Usage
as_torch_optimizer(x, clone = FALSE, ...)Arguments
x | (any) |
clone | ( |
... | (any) |
Value
See Also
Other Torch Descriptor:TorchCallback,TorchDescriptor,TorchLoss,TorchOptimizer,as_torch_callbacks(),as_torch_loss(),mlr3torch_losses,mlr3torch_optimizers,t_clbk(),t_loss(),t_opt()
Assert Lazy Tensor
Description
Asserts whether something is a lazy tensor.
Usage
assert_lazy_tensor(x)Arguments
x | (any) |
Auto Device
Description
First tries cuda, then cpu.
Usage
auto_device(device = NULL)Arguments
device | ( |
Batchgetter for Categorical data
Description
Converts a data frame of categorical data into a long tensor by converting the data to integers.No input checks are performed.
Usage
batchgetter_categ(data, ...)Arguments
data | ( |
... | (any) |
Batchgetter for Numeric Data
Description
Converts a data frame of numeric data into a float tensor by callingas.matrix().No input checks are performed
Usage
batchgetter_num(data, ...)Arguments
data | ( |
... | (any) |
Create a Set of Callbacks for Torch
Description
Creates anR6ClassGenerator inheriting fromCallbackSet.Additionally performs checks such as that the stages are not accidentally misspelled.To create aTorchCallback usetorch_callback().
In order for the resulting class to be cloneable, the private method$deep_clone() must beprovided.
Usage
callback_set( classname, on_begin = NULL, on_end = NULL, on_exit = NULL, on_epoch_begin = NULL, on_before_valid = NULL, on_epoch_end = NULL, on_batch_begin = NULL, on_batch_end = NULL, on_after_backward = NULL, on_batch_valid_begin = NULL, on_batch_valid_end = NULL, on_valid_end = NULL, state_dict = NULL, load_state_dict = NULL, initialize = NULL, public = NULL, private = NULL, active = NULL, parent_env = parent.frame(), inherit = CallbackSet, lock_objects = FALSE)Arguments
classname | ( |
on_begin,on_end,on_epoch_begin,on_before_valid,on_epoch_end,on_batch_begin,on_batch_end,on_after_backward,on_batch_valid_begin,on_batch_valid_end,on_valid_end,on_exit | ( |
state_dict | ( |
load_state_dict | ( |
initialize | ( |
public,private,active | ( |
parent_env | ( |
inherit | ( |
lock_objects | ( |
Value
See Also
Other Callback:TorchCallback,as_torch_callback(),as_torch_callbacks(),mlr3torch_callbacks,mlr_callback_set,mlr_callback_set.checkpoint,mlr_callback_set.progress,mlr_callback_set.tb,mlr_callback_set.unfreeze,mlr_context_torch,t_clbk(),torch_callback()
Cross Entropy Loss
Description
Thecross_entropy loss function selects the multi-class (nn_cross_entropy_loss)or binary (nn_bce_with_logits_loss) cross entropyloss based on the number of classes.Because of this, there is a slight reparameterization of the loss arguments, seeParameters.
Parameters
class_weight::torch_tensor
The class weights. For multi-class problems, this must be atorch_tensorof lengthnum_classes(and is passed as argumentweighttonn_cross_entropy_loss).For binary problems, this must be a scalar (and is passed as argumentpos_weighttonn_bce_with_logits_loss).
ignore_index::integer(1)
Index of the class which to ignore and which does not contribute to the gradient.This is only available for multi-class loss.reduction::character(1)
The reduction to apply. Is either"mean"or"sum"and passed as argumentreductionto either loss function. The default is"mean".
Examples
loss = t_loss("cross_entropy")# multi-classmulti_ce = loss$generate(tsk("iris"))multi_ce# binarybinary_ce = loss$generate(tsk("sonar"))binary_ceInfer Shapes
Description
Infer the shapes of the output of a function based on the shapes of the input.This is done as follows:
All
NAs are replaced with values1,2,3.Three tensors are generated for the three shapes of step 1.
The function is called on these three tensors and the shapes are calculated.
If:
the number of dimensions varies, an error is thrown.
the number of dimensions is the same, values are set to
NAif the dimension is varyingbetween the three tensors and otherwise set to the unique value.
Usage
infer_shapes(shapes_in, param_vals, output_names, fn, rowwise, id)Arguments
shapes_in | ( |
param_vals | ( |
output_names | ( |
fn | ( |
rowwise | ( |
id | ( |
Value
(list())
A list of shapes of the output tensors.
Ingress Token for Categorical Features
Description
Represents an entry point representing a tensor containing all categorical (factor(),ordered(),logical())features of a task.
Usage
ingress_categ(shape = NULL)Arguments
shape | ( |
Value
Ingress Token for Lazy Tensor Feature
Description
Represents an entry point representing a tensor containing a single lazy tensor feature.
Usage
ingress_ltnsr(feature_name = NULL, shape = NULL)Arguments
feature_name | ( |
shape | ( |
Value
Ingress Token for Numeric Features
Description
Represents an entry point representing a tensor containing all numeric (integer() anddouble())features of a task.
Usage
ingress_num(shape = NULL)Arguments
shape | ( |
Value
Check for lazy tensor
Description
Checks whether an object is a lazy tensor.
Usage
is_lazy_tensor(x)Arguments
x | (any) |
Shape of Lazy Tensor
Description
Shape of a lazy tensor. Might beNULL if the shapes is not known or varying between rows.Batch dimension is alwaysNA.
Usage
lazy_shape(x)Arguments
x | ( |
Value
(integer() orNULL)
Examples
lt = as_lazy_tensor(1:10)lazy_shape(lt)lt = as_lazy_tensor(matrix(1:10, nrow = 2))lazy_shape(lt)Create a lazy tensor
Description
Create a lazy tensor.
Usage
lazy_tensor(data_descriptor = NULL, ids = NULL)Arguments
data_descriptor | ( |
ids | ( |
Examples
ds = dataset("example", initialize = function() self$iris = iris[, -5], .getitem = function(i) list(x = torch_tensor(as.numeric(self$iris[i, ]))), .length = function() nrow(self$iris))()dd = as_data_descriptor(ds, list(x = c(NA, 4L)))lt = as_lazy_tensor(dd)Materialize Lazy Tensor Columns
Description
This will materialize alazy_tensor() or adata.frame() /list() containing – among other things –lazy_tensor() columns.I.e. the data described in the underlyingDataDescriptors is loaded for the indices in thelazy_tensor(),is preprocessed and then put unto the specified device.Because not all elements in a lazy tensor must have the same shape, a list of tensors is returned by default.If all elements have the same shape, these tensors can also be rbinded into a single tensor (parameterrbind).
Usage
materialize(x, device = "cpu", rbind = FALSE, ...)## S3 method for class 'list'materialize(x, device = "cpu", rbind = FALSE, cache = "auto", ...)Arguments
x | (any) |
device | ( |
rbind | ( |
... | (any) |
cache | ( |
Details
Materializing a lazy tensor consists of:
Loading the data from the internal dataset of the
DataDescriptor.Processing these batches in the preprocessing
Graphs.Returning the result of the
PipeOppointed to by theDataDescriptor(pointer).
With multiplelazy_tensor columns we can benefit from caching because:a) Output(s) from the dataset might be input to multiple graphs.b) Different lazy tensors might be outputs from the same graph.
For this reason it is possible to provide a cache environment.The hash key for a) is the hash of the indices and the dataset.The hash key for b) is the hash of the indices, dataset and preprocessing graph.
Value
(list() oflazy_tensors or alazy_tensor)
Examples
lt1 = as_lazy_tensor(torch_randn(10, 3))materialize(lt1, rbind = TRUE)materialize(lt1, rbind = FALSE)lt2 = as_lazy_tensor(torch_randn(10, 4))d = data.table::data.table(lt1 = lt1, lt2 = lt2)materialize(d, rbind = TRUE)materialize(d, rbind = FALSE)Materialize a Lazy Tensor
Description
Convert alazy_tensor to atorch_tensor.
Usage
materialize_internal(x, device = "cpu", cache = NULL, rbind)Arguments
x | ( |
device | ( |
cache | ( |
rbind | ( |
Details
Materializing a lazy tensor consists of:
Loading the data from the internal dataset of the
DataDescriptor.Processing these batches in the preprocessing
Graphs.Returning the result of the
PipeOppointed to by theDataDescriptor(pointer).
When materializing multiplelazy_tensor columns, caching can be useful because:a) Output(s) from the dataset might be input to multiple graphs.(in task_dataset this is shoudl rarely be the case because because we try to merge them).b) Different lazy tensors might be outputs from the same graph.
For this reason it is possible to provide a cache environment.The hash key for a) is the hash of the indices and the dataset.The hash key for b) is the hash of the indices dataset and preprocessing graph.
Value
Dictionary of Torch Callbacks
Description
Amlr3misc::Dictionary of torch callbacks.Uset_clbk() to conveniently retrieve callbacks.Can be converted to adata.table usingas.data.table.
Usage
mlr3torch_callbacksFormat
An object of classDictionaryMlr3torchCallbacks (inherits fromDictionary,R6) of length 12.
See Also
Other Callback:TorchCallback,as_torch_callback(),as_torch_callbacks(),callback_set(),mlr_callback_set,mlr_callback_set.checkpoint,mlr_callback_set.progress,mlr_callback_set.tb,mlr_callback_set.unfreeze,mlr_context_torch,t_clbk(),torch_callback()
Other Dictionary:mlr3torch_losses,mlr3torch_optimizers,t_opt()
Examples
mlr3torch_callbacks$get("checkpoint")# is the same ast_clbk("checkpoint")# convert to a data.tableas.data.table(mlr3torch_callbacks)Loss Functions
Description
Dictionary of torch loss descriptors.Seet_loss() for conveniently retrieving a loss function.Can be converted to adata.table usingas.data.table.
Usage
mlr3torch_lossesFormat
An object of classDictionaryMlr3torchLosses (inherits fromDictionary,R6) of length 12.
Available Loss Functions
cross_entropy, l1, mse
See Also
Other Torch Descriptor:TorchCallback,TorchDescriptor,TorchLoss,TorchOptimizer,as_torch_callbacks(),as_torch_loss(),as_torch_optimizer(),mlr3torch_optimizers,t_clbk(),t_loss(),t_opt()
Other Dictionary:mlr3torch_callbacks,mlr3torch_optimizers,t_opt()
Examples
mlr3torch_losses$get("mse")# is equivalent tot_loss("mse")# convert to a data.tableas.data.table(mlr3torch_losses)Optimizers
Description
Dictionary of torch optimizers.Uset_opt for conveniently retrieving optimizers.Can be converted to adata.table usingas.data.table.
Usage
mlr3torch_optimizersFormat
An object of classDictionaryMlr3torchOptimizers (inherits fromDictionary,R6) of length 12.
Available Optimizers
adagrad, adam, adamw, rmsprop, sgd
See Also
Other Torch Descriptor:TorchCallback,TorchDescriptor,TorchLoss,TorchOptimizer,as_torch_callbacks(),as_torch_loss(),as_torch_optimizer(),mlr3torch_losses,t_clbk(),t_loss(),t_opt()
Other Dictionary:mlr3torch_callbacks,mlr3torch_losses,t_opt()
Examples
mlr3torch_optimizers$get("adam")# is equivalent tot_opt("adam")# convert to a data.tableas.data.table(mlr3torch_optimizers)Lazy Data Backend
Description
This lazy data backend wraps a constructor that lazily creates another backend, e.g. by downloading(and caching) some data from the internet.This backend should be used, when some metadata of the backend is known in advance and should be accessiblebefore downloading the actual data.When the backend is first constructed, it is verified that the provided metadata was correct, otherwisean informative error message is thrown.After the construction of the lazily constructed backend, calls like$data(),$missings(),$distinct(),or$hash() are redirected to it.
Information that is available before the backend is constructed is:
nrow- The number of rows (set as the length of therownames).ncol- The number of columns (provided via theidcolumn ofcol_info).colnames- The column names.rownames- The row names.col_info- The column information, which can be obtained viamlr3::col_info().
Beware that accessing the backend's hash also contructs the backend.
Note that while in most cases the data containslazy_tensor columns, this is not necessary and the namingof this class has nothing to do with thelazy_tensor data type.
Important
When the constructor generatesfactor() variables it is important that the ordering of the levels in datacorresponds to the ordering of the levels in thecol_info argument.
Super class
mlr3::DataBackend ->DataBackendLazy
Active bindings
backend(
DataBackend)
The wrapped backend that is lazily constructed when first accessed.nrow(
integer(1))
Number of rows (observations).ncol(
integer(1))
Number of columns (variables), including the primary key column.rownames(
integer())
Returns vector of all distinct row identifiers, i.e. the contents of the primary key column.colnames(
character())
Returns vector of all column names, including the primary key column.is_constructed(
logical(1))
Whether the backend has already been constructed.
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
DataBackendLazy$new(constructor, rownames, col_info, primary_key)
Arguments
constructor(
function)
A function with argumentbackend(the lazy backend), whose return value must be the actual backend.This function is called the first time the field$backendis accessed.rownames(
integer())
The row names. Must be a permutation of the rownames of the lazily constructed backend.col_info(
data.table::data.table())
A data.table with columnsid,typeandlevelscontaining the column id, type and levels.Note that the levels must be provided in the correct order.primary_key(
character(1))
Name of the primary key column.
Methoddata()
Returns a slice of the data in the specified format.The rows must be addressed as vector of primary key values, columns must be referred to via column names.Queries for rows with no matching row id and queries for columns with no matching column name are silently ignored.Rows are guaranteed to be returned in the same order asrows, columns may be returned in an arbitrary order.Duplicated row ids result in duplicated rows, duplicated column names lead to an exception.
Accessing the data triggers the construction of the backend.
Usage
DataBackendLazy$data(rows, cols)
Arguments
rows(
integer())
Row indices.cols(
character())
Column names.
Methodhead()
Retrieve the firstn rows.This triggers the construction of the backend.
Usage
DataBackendLazy$head(n = 6L)
Arguments
n(
integer(1))
Number of rows.
Returns
data.table::data.table() of the firstn rows.
Methoddistinct()
Returns a named list of vectors of distinct values for each columnspecified. Ifna_rm isTRUE, missing values are removed from thereturned vectors of distinct values. Non-existing rows and columns aresilently ignored.
This triggers the construction of the backend.
Usage
DataBackendLazy$distinct(rows, cols, na_rm = TRUE)
Arguments
rows(
integer())
Row indices.cols(
character())
Column names.na_rm(
logical(1))
Whether to remove NAs or not.
Returns
Namedlist() of distinct values.
Methodmissings()
Returns the number of missing values per column in the specified sliceof data. Non-existing rows and columns are silently ignored.
This triggers the construction of the backend.
Usage
DataBackendLazy$missings(rows, cols)
Arguments
rows(
integer())
Row indices.cols(
character())
Column names.
Returns
Total of missing values per column (namednumeric()).
Methodprint()
Printer.
Usage
DataBackendLazy$print()
Examples
# We first define a backend constructorconstructor = function(backend) { cat("Data is constructed!\n") DataBackendDataTable$new( data.table(x = rnorm(10), y = rnorm(10), row_id = 1:10), primary_key = "row_id" )}# to wrap this backend constructor in a lazy backend, we need to provide the correct metadata for itcolumn_info = data.table( id = c("x", "y", "row_id"), type = c("numeric", "numeric", "integer"), levels = list(NULL, NULL, NULL))backend_lazy = DataBackendLazy$new( constructor = constructor, rownames = 1:10, col_info = column_info, primary_key = "row_id")# Note that the constructor is not called for the calls below# as they can be read from the metadatabackend_lazy$nrowbackend_lazy$rownamesbackend_lazy$ncolbackend_lazy$colnamescol_info(backend_lazy)# Only now the backend is constructedbackend_lazy$data(1, "x")# Is the same as:backend_lazy$backend$data(1, "x")Base Class for Callbacks
Description
Base class from which callbacks should inherit (see sectionInheriting).A callback set is a collection of functions that are executed at different stages of the training loop.They can be used to gain more control over the training process of a neural network withouthaving to write everything from scratch.
When used a in torch learner, theCallbackSet is wrapped in aTorchCallback.The latters parameter set represents the arguments of theCallbackSet's$initialize() method.
Inheriting
For each available stage (see sectionStages) a public method$on_<stage>() can be defined.The evaluation context (aContextTorch) can be accessed viaself$ctx, which containsthe current state of the training loop.This context is assigned at the beginning of the training loop and removed afterwards.Different stages of a callback can communicate with each other by assigning values to$self.
State:To be able to store information in the$model slot of aLearnerTorch, callbacks support a state API.You can overload the$state_dict() public method to define what will be stored inlearner$model$callbacks$<id>after training finishes.This then also requires to implement a$load_state_dict(state_dict) method that defines how to load a previously savedcallback state into a different callback.Note that the$state_dict() should not include the parameter values that were used to initialize the callback.
For creating custom callbacks, the functiontorch_callback() is recommended, which creates aCallbackSet and then wraps it in aTorchCallback.To create aCallbackSet the convenience functioncallback_set() can be used.These functions perform checks such as that the stages are not accidentally misspelled.
Stages
begin:: Run before the training loop begins.epoch_begin:: Run he beginning of each epoch.batch_begin:: Run before the forward call.after_backward:: Run after the backward call.batch_end:: Run after the optimizer step.batch_valid_begin:: Run before the forward call in the validation loop.batch_valid_end:: Run after the forward call in the validation loop.valid_end:: Run at the end of validation.epoch_end:: Run at the end of each epoch.end:: Run after last epoch.exit:: Run at last, usingon.exit().
Terminate Training
If training is to be stopped, it is possible to set the field$terminate ofContextTorch.At the end of every epoch this field is checked and if it isTRUE, training stops.This can for example be used to implement custom early stopping.
Public fields
ctx(
ContextTorchorNULL)
The evaluation context for the callback.This field should always beNULLexcept during the$train()call of the torch learner.
Active bindings
stages(
character())
The active stages of this callback set.
Methods
Public methods
Methodprint()
Prints the object.
Usage
CallbackSet$print(...)
Arguments
...(any)
Currently unused.
Methodstate_dict()
Returns information that is kept in the theLearnerTorch's state after training.This information should be loadable into the callback using$load_state_dict() to be able to continue training.This returnsNULL by default.
Usage
CallbackSet$state_dict()
Methodload_state_dict()
Loads the state dict into the callback to continue training.
Usage
CallbackSet$load_state_dict(state_dict)
Arguments
state_dict(any)
The state dict as retrieved via$state_dict().
Methodclone()
The objects of this class are cloneable with this method.
Usage
CallbackSet$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Callback:TorchCallback,as_torch_callback(),as_torch_callbacks(),callback_set(),mlr3torch_callbacks,mlr_callback_set.checkpoint,mlr_callback_set.progress,mlr_callback_set.tb,mlr_callback_set.unfreeze,mlr_context_torch,t_clbk(),torch_callback()
Checkpoint Callback
Description
Saves the optimizer and network states during training.The final network and optimizer are always stored.
Details
Saving the learner itself in the callback with a trained model is impossible,as the model slot is setafter the last callback step is executed.
Super class
mlr3torch::CallbackSet ->CallbackSetCheckpoint
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
CallbackSetCheckpoint$new(path, freq, freq_type = "epoch")
Arguments
path(
character(1))
The path to a folder where the models are saved.freq(
integer(1))
The frequency how often the model is saved.Frequency is either per step or epoch, which can be configured through thefreq_typeparameter.freq_type(
character(1))
Can be be either"epoch"(default) or"step".
Methodon_epoch_end()
Saves the network and optimizer state dict.Does nothing iffreq_type orfreq are not met.
Usage
CallbackSetCheckpoint$on_epoch_end()
Methodon_batch_end()
Saves the selected objects defined insave.Does nothing if freq_type or freq are not met.
Usage
CallbackSetCheckpoint$on_batch_end()
Methodon_exit()
Saves the learner.
Usage
CallbackSetCheckpoint$on_exit()
Methodclone()
The objects of this class are cloneable with this method.
Usage
CallbackSetCheckpoint$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Callback:TorchCallback,as_torch_callback(),as_torch_callbacks(),callback_set(),mlr3torch_callbacks,mlr_callback_set,mlr_callback_set.progress,mlr_callback_set.tb,mlr_callback_set.unfreeze,mlr_context_torch,t_clbk(),torch_callback()
Examples
cb = t_clbk("checkpoint", freq = 1)task = tsk("iris")pth = tempfile()learner = lrn("classif.mlp", epochs = 3, batch_size = 1, callbacks = cb)learner$param_set$set_values(cb.checkpoint.path = pth)learner$train(task)list.files(pth)History Callback
Description
Saves the training and validation history during training.The history is saved as a data.table where the validation measures are prefixed with"valid."and the training measures are prefixed with"train.".
Super class
mlr3torch::CallbackSet ->CallbackSetHistory
Methods
Public methods
Inherited methods
Methodon_begin()
Initializes lists where the train and validation metrics are stored.
Usage
CallbackSetHistory$on_begin()
Methodstate_dict()
Converts the lists to data.tables.
Usage
CallbackSetHistory$state_dict()
Methodload_state_dict()
Sets the field$train and$valid to those contained in the state dict.
Usage
CallbackSetHistory$load_state_dict(state_dict)
Arguments
state_dict(
callback_state_history)
The state dict as retrieved via$state_dict().
Methodon_before_valid()
Add the latest training scores to the history.
Usage
CallbackSetHistory$on_before_valid()
Methodon_epoch_end()
Add the latest validation scores to the history.
Usage
CallbackSetHistory$on_epoch_end()
Methodclone()
The objects of this class are cloneable with this method.
Usage
CallbackSetHistory$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
cb = t_clbk("history")task = tsk("iris")learner = lrn("classif.mlp", epochs = 3, batch_size = 1, callbacks = t_clbk("history"), validate = 0.3)learner$param_set$set_values( measures_train = msrs(c("classif.acc", "classif.ce")), measures_valid = msr("classif.ce"))learner$train(task)print(learner$model$callbacks$history)Learning Rate Scheduling Callback
Description
Changes the learning rate based on the schedule specified by atorch::lr_scheduler.
As of this writing, the following are available:
torch::lr_one_cycle()(where the default values forepochsandsteps_per_epochare the number of training epochs and the number of batches per epoch)Custom schedulers defined with
torch::lr_scheduler().
Super class
mlr3torch::CallbackSet ->CallbackSetLRScheduler
Public fields
scheduler_fn(
lr_scheduler_generator)
Thetorchfunction that creates a learning rate schedulerscheduler(
LRScheduler)
The learning rate scheduler wrapped by this callback
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
CallbackSetLRScheduler$new(.scheduler, step_on_epoch, ...)
Arguments
.scheduler(
lr_scheduler_generator)
Thetorchscheduler generator (e.g.torch::lr_step).step_on_epoch(
logical(1))
Whether the scheduler steps after every epoch (otherwise every batch)....(any)
The scheduler-specific initialization arguments.
Methodon_begin()
Creates the scheduler using the optimizer from the context
Usage
CallbackSetLRScheduler$on_begin()
Methodclone()
The objects of this class are cloneable with this method.
Usage
CallbackSetLRScheduler$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
OneCycle Learning Rate Scheduling Callback
Description
Changes the learning rate based on the 1cycle learning rate policy.
Wrapstorch::lr_one_cycle(), where the default values forepochs andsteps_per_epoch are the number of training epochs and the number of batches per epoch.
Super classes
mlr3torch::CallbackSet ->mlr3torch::CallbackSetLRScheduler ->CallbackSetLRSchedulerOneCycle
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
CallbackSetLRSchedulerOneCycle$new(...)
Arguments
...(any)
The scheduler-specific initialization arguments.
Methodon_begin()
Creates the scheduler using the optimizer from the context
Usage
CallbackSetLRSchedulerOneCycle$on_begin()
Methodclone()
The objects of this class are cloneable with this method.
Usage
CallbackSetLRSchedulerOneCycle$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Reduce On Plateau Learning Rate Scheduler
Description
Reduces the learning rate when the first validation metric stops improving forpatience epochs.Wrapstorch::lr_reduce_on_plateau()
Super classes
mlr3torch::CallbackSet ->mlr3torch::CallbackSetLRScheduler ->CallbackSetLRSchedulerReduceOnPlateau
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
CallbackSetLRSchedulerReduceOnPlateau$new(...)
Arguments
...(any)
The scheduler-specific initialization arguments.
Methodclone()
The objects of this class are cloneable with this method.
Usage
CallbackSetLRSchedulerReduceOnPlateau$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Progress Callback
Description
Prints a progress bar and the metrics for training and validation.
Super class
mlr3torch::CallbackSet ->CallbackSetProgress
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
CallbackSetProgress$new(digits = 2)
Arguments
digitsinteger(1)
The number of digits to print for the measures.
Methodon_epoch_begin()
Initializes the progress bar for training.
Usage
CallbackSetProgress$on_epoch_begin()
Methodon_batch_end()
Increments the training progress bar.
Usage
CallbackSetProgress$on_batch_end()
Methodon_before_valid()
Creates the progress bar for validation.
Usage
CallbackSetProgress$on_before_valid()
Methodon_batch_valid_end()
Increments the validation progress bar.
Usage
CallbackSetProgress$on_batch_valid_end()
Methodon_epoch_end()
Prints a summary of the training and validation process.
Usage
CallbackSetProgress$on_epoch_end()
Methodon_end()
Prints the time at the end of training.
Usage
CallbackSetProgress$on_end()
Methodclone()
The objects of this class are cloneable with this method.
Usage
CallbackSetProgress$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Callback:TorchCallback,as_torch_callback(),as_torch_callbacks(),callback_set(),mlr3torch_callbacks,mlr_callback_set,mlr_callback_set.checkpoint,mlr_callback_set.tb,mlr_callback_set.unfreeze,mlr_context_torch,t_clbk(),torch_callback()
Examples
task = tsk("iris")learner = lrn("classif.mlp", epochs = 5, batch_size = 1, callbacks = t_clbk("progress"), validate = 0.3)learner$param_set$set_values( measures_train = msrs(c("classif.acc", "classif.ce")), measures_valid = msr("classif.ce"))learner$train(task)TensorBoard Logging Callback
Description
Logs training loss, training measures, and validation measures as events.To view them, use TensorBoard withtensorflow::tensorboard() (requirestensorflow) or the CLI.
Details
Logs events at most every epoch.
Super class
mlr3torch::CallbackSet ->CallbackSetTB
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
CallbackSetTB$new(path, log_train_loss)
Arguments
path(
character(1))
The path to a folder where the events are logged.Point TensorBoard to this folder to view them.log_train_loss(
logical(1))
Whether we log the training loss.
Methodon_epoch_end()
Logs the training loss, training measures, and validation measures as TensorBoard events.
Usage
CallbackSetTB$on_epoch_end()
Methodclone()
The objects of this class are cloneable with this method.
Usage
CallbackSetTB$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Callback:TorchCallback,as_torch_callback(),as_torch_callbacks(),callback_set(),mlr3torch_callbacks,mlr_callback_set,mlr_callback_set.checkpoint,mlr_callback_set.progress,mlr_callback_set.unfreeze,mlr_context_torch,t_clbk(),torch_callback()
Unfreezing Weights Callback
Description
Unfreeze some weights (parameters of the network) after some number of steps or epochs.
Super class
mlr3torch::CallbackSet ->CallbackSetUnfreeze
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
CallbackSetUnfreeze$new(starting_weights, unfreeze)
Arguments
starting_weights(
Select)
ASelectdenoting the weights that are trainable from the start.unfreeze(
data.table)
Adata.tablewith a columnweights(a list column ofSelects) and a columnepochorbatch.The selector indicates which parameters to unfreeze, while theepochorbatchcolumn indicates when to do so.
Methodon_begin()
Sets the starting weights
Usage
CallbackSetUnfreeze$on_begin()
Methodon_epoch_begin()
Unfreezes weights if the training is at the correct epoch
Usage
CallbackSetUnfreeze$on_epoch_begin()
Methodon_batch_begin()
Unfreezes weights if the training is at the correct batch
Usage
CallbackSetUnfreeze$on_batch_begin()
Methodclone()
The objects of this class are cloneable with this method.
Usage
CallbackSetUnfreeze$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Callback:TorchCallback,as_torch_callback(),as_torch_callbacks(),callback_set(),mlr3torch_callbacks,mlr_callback_set,mlr_callback_set.checkpoint,mlr_callback_set.progress,mlr_callback_set.tb,mlr_context_torch,t_clbk(),torch_callback()
Examples
task = tsk("iris")cb = t_clbk("unfreeze")mlp = lrn("classif.mlp", callbacks = cb, cb.unfreeze.starting_weights = select_invert( select_name(c("0.weight", "3.weight", "6.weight", "6.bias")) ), cb.unfreeze.unfreeze = data.table( epoch = c(2, 5), weights = list(select_name("0.weight"), select_name(c("3.weight", "6.weight"))) ), epochs = 6, batch_size = 150, neurons = c(1, 1, 1))mlp$train(task)Context for Torch Learner
Description
Context for training a torch learner.This is the - mostly read-only - information callbacks have access to through the argumentctx.For more information on callbacks, seeCallbackSet.
Public fields
learner(
Learner)
The torch learner.task_train(
Task)
The training task.task_valid(
TaskorNULL)
The validation task.loader_train(
torch::dataloader)
The data loader for training.loader_valid(
torch::dataloader)
The data loader for validation.measures_train(
list()ofMeasures)
Measures used for training.measures_valid(
list()ofMeasures)
Measures used for validation.network(
torch::nn_module)
The torch network.optimizer(
torch::optimizer)
The optimizer.loss_fn(
torch::nn_module)
The loss function.total_epochs(
integer(1))
The total number of epochs the learner is trained for.last_scores_train(named
list()orNULL)
The scores from the last training batch. Names are the ids of the training measures.IfLearnerTorchsetseval_freqdifferent from1, this isNULLin all epochsthat don't evaluate the model.last_scores_valid(
list())
The scores from the last validation batch. Names are the ids of the validation measures.IfLearnerTorchsetseval_freqdifferent from1, this isNULLin all epochsthat don't evaluate the model.last_loss(
numeric(1))
The loss from the last trainings batch.y_hat(
torch_tensor)
The model's prediction for the current batch.epoch(
integer(1))
The current epoch.step(
integer(1))
The current iteration.prediction_encoder(
function())
The learner's prediction encoder.batch(named
list()oftorch_tensors)
The current batch.terminate(
logical(1))
If this field is set toTRUEat the end of an epoch, training stops.device(
torch::torch_device)
The device.
Methods
Public methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
ContextTorch$new( learner, task_train, task_valid = NULL, loader_train, loader_valid = NULL, measures_train = NULL, measures_valid = NULL, network, optimizer, loss_fn, total_epochs, prediction_encoder, eval_freq = 1L, device)
Arguments
learner(
Learner)
The torch learner.task_train(
Task)
The training task.task_valid(
TaskorNULL)
The validation task.loader_train(
torch::dataloader)
The data loader for training.loader_valid(
torch::dataloaderorNULL)
The data loader for validation.measures_train(
list()ofMeasures orNULL)
Measures used for training. Default isNULL.measures_valid(
list()ofMeasures orNULL)
Measures used for validation.network(
torch::nn_module)
The torch network.optimizer(
torch::optimizer)
The optimizer.loss_fn(
torch::nn_module)
The loss function.total_epochs(
integer(1))
The total number of epochs the learner is trained for.prediction_encoder(
function())
The learner's prediction encoder.See sectionInheriting ofLearnerTorch.eval_freq(
integer(1))
The evaluation frequency.device(
character(1))
The device.
Methodclone()
The objects of this class are cloneable with this method.
Usage
ContextTorch$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Callback:TorchCallback,as_torch_callback(),as_torch_callbacks(),callback_set(),mlr3torch_callbacks,mlr_callback_set,mlr_callback_set.checkpoint,mlr_callback_set.progress,mlr_callback_set.tb,mlr_callback_set.unfreeze,t_clbk(),torch_callback()
FT-Transformer
Description
Feature-Tokenizer Transformer for tabular data that can either work onlazy_tensor inputsor on standard tabular features.
Some differences from the paper implementation: no attention compression, no option to have prenormalization in the first layer.
If training is unstable, consider a combination of standardizing features (e.g. usingpo("scale")), using an adaptive optimizer (e.g. Adam), reducing the learning rate,and using a learning rate scheduler (seeCallbackSetLRScheduler for options).
Dictionary
ThisLearner can be instantiated using the sugar functionlrn():
lrn("classif.ft_transformer", ...)lrn("regr.ft_transformer", ...)Properties
Supported task types: 'classif', 'regr'
Predict Types:
classif: 'response', 'prob'
regr: 'response'
Feature Types: “logical”, “integer”, “numeric”, “factor”, “ordered”, “lazy_tensor”
Parameters
Parameters fromLearnerTorch andPipeOpTorchFTTransformerBlock, as well as:
n_blocks::integer(1)
The number of transformer blocks.d_token::integer(1)
The dimension of the embedding.cardinalities::integer(1)
The number of categories for each categorical feature. This only needs to be specified when working withlazy_tensorinputs.init_token::character(1)
The initialization method for the embedding weights. Either "uniform" or "normal". "Uniform" by default.ingress_tokens:: namedlist()orNULL
A list ofTorchIngressTokens. Only required when using lazy tensor features.The names are either "num.input" or "categ.input", and the values are lazy tensor ingress tokens constructed by, e.g.ingress_ltnsr(<num_feat_name>).
Super classes
mlr3::Learner ->mlr3torch::LearnerTorch ->LearnerTorchFTTransformer
Methods
Public methods
Inherited methods
mlr3::Learner$base_learner()mlr3::Learner$configure()mlr3::Learner$encapsulate()mlr3::Learner$help()mlr3::Learner$predict()mlr3::Learner$predict_newdata()mlr3::Learner$reset()mlr3::Learner$selected_features()mlr3::Learner$train()mlr3torch::LearnerTorch$dataset()mlr3torch::LearnerTorch$format()mlr3torch::LearnerTorch$marshal()mlr3torch::LearnerTorch$print()mlr3torch::LearnerTorch$unmarshal()
Methodnew()
Creates a new instance of thisR6 class.
Usage
LearnerTorchFTTransformer$new( task_type, optimizer = NULL, loss = NULL, callbacks = list())
Arguments
task_type(
character(1))
The task type, either"classif" or"regr".optimizer(
TorchOptimizer)
The optimizer to use for training.Per default,adam is used.loss(
TorchLoss)
The loss used to train the network.Per default,mse is used for regression andcross_entropy for classification.callbacks(
list()ofTorchCallbacks)
The callbacks. Must have unique ids.
Methodclone()
The objects of this class are cloneable with this method.
Usage
LearnerTorchFTTransformer$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
References
Gorishniy Y, Rubachev I, Khrulkov V, Babenko A (2021).“Revisiting Deep Learning for Tabular Data.”arXiv,2106.11959.
See Also
Other Learner:mlr_learners.mlp,mlr_learners.module,mlr_learners.tab_resnet,mlr_learners.torch_featureless,mlr_learners_torch,mlr_learners_torch_image,mlr_learners_torch_model
Examples
# Define the Learner and set parameter valueslearner = lrn("classif.ft_transformer")learner$param_set$set_values( epochs = 1, batch_size = 16, device = "cpu", n_blocks = 2, d_token = 32, ffn_d_hidden_multiplier = 4/3)# Define a Tasktask = tsk("iris")# Create train and test setids = partition(task)# Train the learner on the training idslearner$train(task, row_ids = ids$train)# Make predictions for the test rowspredictions = learner$predict(task, row_ids = ids$test)# Score the predictionspredictions$score()Multi Layer Perceptron
Description
Fully connected feed forward network with dropout after each activation function.The features can either be a singlelazy_tensor or one or more numeric columns (but not both).
Dictionary
ThisLearner can be instantiated using the sugar functionlrn():
lrn("classif.mlp", ...)lrn("regr.mlp", ...)Properties
Supported task types: 'classif', 'regr'
Predict Types:
classif: 'response', 'prob'
regr: 'response'
Feature Types: “integer”, “numeric”, “lazy_tensor”
Parameters
Parameters fromLearnerTorch, as well as:
activation::[nn_module]
The activation function. Is initialized tonn_relu.activation_args:: namedlist()
A named list with initialization arguments for the activation function.This is intialized to an empty list.neurons::integer()
The number of neurons per hidden layer. By default there is no hidden layer.Setting this toc(10, 20)would have a the first hidden layer with 10 neurons and the second with 20.n_layers::integer()
The number of layers. This parameter must only be set whenneuronshas length 1.p::numeric(1)
The dropout probability. Is initialized to0.5.shape::integer()orNULL
The input shape of length 2, e.g.c(NA, 5).Only needs to be present when there is a lazy tensor input with unknown shape (NULL).Otherwise the input shape is inferred from the number of numeric features.
Super classes
mlr3::Learner ->mlr3torch::LearnerTorch ->LearnerTorchMLP
Methods
Public methods
Inherited methods
mlr3::Learner$base_learner()mlr3::Learner$configure()mlr3::Learner$encapsulate()mlr3::Learner$help()mlr3::Learner$predict()mlr3::Learner$predict_newdata()mlr3::Learner$reset()mlr3::Learner$selected_features()mlr3::Learner$train()mlr3torch::LearnerTorch$dataset()mlr3torch::LearnerTorch$format()mlr3torch::LearnerTorch$marshal()mlr3torch::LearnerTorch$print()mlr3torch::LearnerTorch$unmarshal()
Methodnew()
Creates a new instance of thisR6 class.
Usage
LearnerTorchMLP$new( task_type, optimizer = NULL, loss = NULL, callbacks = list())
Arguments
task_type(
character(1))
The task type, either"classif" or"regr".optimizer(
TorchOptimizer)
The optimizer to use for training.Per default,adam is used.loss(
TorchLoss)
The loss used to train the network.Per default,mse is used for regression andcross_entropy for classification.callbacks(
list()ofTorchCallbacks)
The callbacks. Must have unique ids.
Methodclone()
The objects of this class are cloneable with this method.
Usage
LearnerTorchMLP$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
References
Gorishniy Y, Rubachev I, Khrulkov V, Babenko A (2021).“Revisiting Deep Learning for Tabular Data.”arXiv,2106.11959.
See Also
Other Learner:mlr_learners.ft_transformer,mlr_learners.module,mlr_learners.tab_resnet,mlr_learners.torch_featureless,mlr_learners_torch,mlr_learners_torch_image,mlr_learners_torch_model
Examples
# Define the Learner and set parameter valueslearner = lrn("classif.mlp")learner$param_set$set_values( epochs = 1, batch_size = 16, device = "cpu", neurons = 10)# Define a Tasktask = tsk("iris")# Create train and test setids = partition(task)# Train the learner on the training idslearner$train(task, row_ids = ids$train)# Make predictions for the test rowspredictions = learner$predict(task, row_ids = ids$test)# Score the predictionspredictions$score()Learner Torch Module
Description
Create a torch learner from a torch module.
Dictionary
ThisLearner can be instantiated using the sugar functionlrn():
lrn("classif.module", ...)lrn("regr.module", ...)Properties
Supported task types: 'classif', 'regr'
Predict Types:
classif: 'response', 'prob'
regr: 'response'
Feature Types: “logical”, “integer”, “numeric”, “character”, “factor”, “ordered”, “POSIXct”, “Date”, “lazy_tensor”
Super classes
mlr3::Learner ->mlr3torch::LearnerTorch ->LearnerTorchModule
Methods
Public methods
Inherited methods
mlr3::Learner$base_learner()mlr3::Learner$configure()mlr3::Learner$encapsulate()mlr3::Learner$help()mlr3::Learner$predict()mlr3::Learner$predict_newdata()mlr3::Learner$reset()mlr3::Learner$selected_features()mlr3::Learner$train()mlr3torch::LearnerTorch$dataset()mlr3torch::LearnerTorch$format()mlr3torch::LearnerTorch$marshal()mlr3torch::LearnerTorch$print()mlr3torch::LearnerTorch$unmarshal()
Methodnew()
Creates a new instance of thisR6 class.
Usage
LearnerTorchModule$new( module_generator = NULL, param_set = NULL, ingress_tokens = NULL, task_type, properties = NULL, optimizer = NULL, loss = NULL, callbacks = list(), packages = character(0), feature_types = NULL, predict_types = NULL)
Arguments
module_generator(
functionornn_module_generator)
Ann_module_generatororfunctionreturning annn_module.Both must take as argument thetaskfor which to construct the network.Other arguments to its initialize method can be provided as parameters.param_set(
NULLorParamSet)
If provided, contains the parameters for the module_generator.IfNULL, parameters will be inferred from the module_generator.ingress_tokens(
listofTorchIngressToken())
A list with ingress tokens that defines how the dataset will be defined.The names must correspond to the arguments of the network's forward method.For numeric, categorical, and lazy tensor features, you can useingress_num(),ingress_categ(), andingress_ltnsr()to create them.task_type(
character(1))
The task type, either"classif" or"regr".task_type(
character(1))
The task type.properties(
NULLorcharacter())
The properties of the learner.Defaults to all available properties for the given task type.optimizer(
TorchOptimizer)
The optimizer to use for training.Per default,adam is used.loss(
TorchLoss)
The loss used to train the network.Per default,mse is used for regression andcross_entropy for classification.callbacks(
list()ofTorchCallbacks)
The callbacks. Must have unique ids.packages(
character())
The R packages this object depends on.feature_types(
NULLorcharacter())
The feature types. Defaults to all available feature types.predict_types(
character())
The predict types.Seemlr_reflections$learner_predict_typesfor available values.
Methodclone()
The objects of this class are cloneable with this method.
Usage
LearnerTorchModule$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Learner:mlr_learners.ft_transformer,mlr_learners.mlp,mlr_learners.tab_resnet,mlr_learners.torch_featureless,mlr_learners_torch,mlr_learners_torch_image,mlr_learners_torch_model
Other Learner:mlr_learners.ft_transformer,mlr_learners.mlp,mlr_learners.tab_resnet,mlr_learners.torch_featureless,mlr_learners_torch,mlr_learners_torch_image,mlr_learners_torch_model
Examples
nn_one_layer = nn_module("nn_one_layer", initialize = function(task, size_hidden) { self$first = nn_linear(task$n_features, size_hidden) self$second = nn_linear(size_hidden, output_dim_for(task)) }, # argument x corresponds to the ingress token x forward = function(x) { x = self$first(x) x = nnf_relu(x) self$second(x) })learner = lrn("classif.module", module_generator = nn_one_layer, ingress_tokens = list(x = ingress_num()), epochs = 10, size_hidden = 20, batch_size = 16)task = tsk("iris")learner$train(task)learner$networkTabular ResNet
Description
Tabular resnet.
Dictionary
ThisLearner can be instantiated using the sugar functionlrn():
lrn("classif.tab_resnet", ...)lrn("regr.tab_resnet", ...)Properties
Supported task types: 'classif', 'regr'
Predict Types:
classif: 'response', 'prob'
regr: 'response'
Feature Types: “integer”, “numeric”, “lazy_tensor”
Parameters
Parameters fromLearnerTorch, as well as:
n_blocks::integer(1)
The number of blocks.d_block::integer(1)
The input and output dimension of a block.d_hidden::integer(1)
The latent dimension of a block.d_hidden_multiplier::numeric(1)
Alternative way to specify the latent dimension asd_block * d_hidden_multiplier.dropout1::numeric(1)
First dropout ratio.dropout2::numeric(1)
Second dropout ratio.shape::integer()orNULL
Shape of the input tensor. Only needs to be provided if the input is a lazy tensor withunknown shape.
Super classes
mlr3::Learner ->mlr3torch::LearnerTorch ->LearnerTorchTabResNet
Methods
Public methods
Inherited methods
mlr3::Learner$base_learner()mlr3::Learner$configure()mlr3::Learner$encapsulate()mlr3::Learner$help()mlr3::Learner$predict()mlr3::Learner$predict_newdata()mlr3::Learner$reset()mlr3::Learner$selected_features()mlr3::Learner$train()mlr3torch::LearnerTorch$dataset()mlr3torch::LearnerTorch$format()mlr3torch::LearnerTorch$marshal()mlr3torch::LearnerTorch$print()mlr3torch::LearnerTorch$unmarshal()
Methodnew()
Creates a new instance of thisR6 class.
Usage
LearnerTorchTabResNet$new( task_type, optimizer = NULL, loss = NULL, callbacks = list())
Arguments
task_type(
character(1))
The task type, either"classif" or"regr".optimizer(
TorchOptimizer)
The optimizer to use for training.Per default,adam is used.loss(
TorchLoss)
The loss used to train the network.Per default,mse is used for regression andcross_entropy for classification.callbacks(
list()ofTorchCallbacks)
The callbacks. Must have unique ids.
Methodclone()
The objects of this class are cloneable with this method.
Usage
LearnerTorchTabResNet$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
References
Gorishniy Y, Rubachev I, Khrulkov V, Babenko A (2021).“Revisiting Deep Learning for Tabular Data.”arXiv,2106.11959.
See Also
Other Learner:mlr_learners.ft_transformer,mlr_learners.mlp,mlr_learners.module,mlr_learners.torch_featureless,mlr_learners_torch,mlr_learners_torch_image,mlr_learners_torch_model
Examples
# Define the Learner and set parameter valueslearner = lrn("classif.tab_resnet")learner$param_set$set_values( epochs = 1, batch_size = 16, device = "cpu", n_blocks = 2, d_block = 10, d_hidden = 20, dropout1 = 0.3, dropout2 = 0.3)# Define a Tasktask = tsk("iris")# Create train and test setids = partition(task)# Train the learner on the training idslearner$train(task, row_ids = ids$train)# Make predictions for the test rowspredictions = learner$predict(task, row_ids = ids$test)# Score the predictionspredictions$score()Featureless Torch Learner
Description
Featureless torch learner.Output is a constant weight that is learned during training.For classification, this should (asymptoptically) result in a majority class prediction when using the standard cross-entropy loss.For regression, this should result in the median for L1 loss and in the mean for L2 loss.
Dictionary
ThisLearner can be instantiated using the sugar functionlrn():
lrn("classif.torch_featureless", ...)lrn("regr.torch_featureless", ...)Properties
Supported task types: 'classif', 'regr'
Predict Types:
classif: 'response', 'prob'
regr: 'response'
Feature Types: “logical”, “integer”, “numeric”, “character”, “factor”, “ordered”, “POSIXct”, “Date”, “lazy_tensor”
Parameters
Only those fromLearnerTorch.
Super classes
mlr3::Learner ->mlr3torch::LearnerTorch ->LearnerTorchFeatureless
Methods
Public methods
Inherited methods
mlr3::Learner$base_learner()mlr3::Learner$configure()mlr3::Learner$encapsulate()mlr3::Learner$help()mlr3::Learner$predict()mlr3::Learner$predict_newdata()mlr3::Learner$reset()mlr3::Learner$selected_features()mlr3::Learner$train()mlr3torch::LearnerTorch$dataset()mlr3torch::LearnerTorch$format()mlr3torch::LearnerTorch$marshal()mlr3torch::LearnerTorch$print()mlr3torch::LearnerTorch$unmarshal()
Methodnew()
Creates a new instance of thisR6 class.
Usage
LearnerTorchFeatureless$new( task_type, optimizer = NULL, loss = NULL, callbacks = list())
Arguments
task_type(
character(1))
The task type, either"classif" or"regr".optimizer(
TorchOptimizer)
The optimizer to use for training.Per default,adam is used.loss(
TorchLoss)
The loss used to train the network.Per default,mse is used for regression andcross_entropy for classification.callbacks(
list()ofTorchCallbacks)
The callbacks. Must have unique ids.
Methodclone()
The objects of this class are cloneable with this method.
Usage
LearnerTorchFeatureless$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Learner:mlr_learners.ft_transformer,mlr_learners.mlp,mlr_learners.module,mlr_learners.tab_resnet,mlr_learners_torch,mlr_learners_torch_image,mlr_learners_torch_model
Examples
# Define the Learner and set parameter valueslearner = lrn("classif.torch_featureless")learner$param_set$set_values( epochs = 1, batch_size = 16, device = "cpu" )# Define a Tasktask = tsk("iris")# Create train and test setids = partition(task)# Train the learner on the training idslearner$train(task, row_ids = ids$train)# Make predictions for the test rowspredictions = learner$predict(task, row_ids = ids$test)# Score the predictionspredictions$score()AlexNet Image Classifier
Description
Classic image classification networks fromtorchvision.
Parameters
Parameters fromLearnerTorchImage and
pretrained::logical(1)
Whether to use the pretrained model.The final linear layer will be replaced with a newnn_linearwith thenumber of classes inferred from theTask.
Properties
Supported task types:
"classif"Predict Types:
"response"and"prob"Feature Types:
"lazy_tensor"Required packages:
"mlr3torch","torch","torchvision"
Super classes
mlr3::Learner ->mlr3torch::LearnerTorch ->mlr3torch::LearnerTorchImage ->LearnerTorchVision
Methods
Public methods
Inherited methods
mlr3::Learner$base_learner()mlr3::Learner$configure()mlr3::Learner$encapsulate()mlr3::Learner$help()mlr3::Learner$predict()mlr3::Learner$predict_newdata()mlr3::Learner$reset()mlr3::Learner$selected_features()mlr3::Learner$train()mlr3torch::LearnerTorch$dataset()mlr3torch::LearnerTorch$format()mlr3torch::LearnerTorch$marshal()mlr3torch::LearnerTorch$print()mlr3torch::LearnerTorch$unmarshal()
Methodnew()
Creates a new instance of thisR6 class.
Usage
LearnerTorchVision$new( name, module_generator, label, optimizer = NULL, loss = NULL, callbacks = list(), jittable = FALSE)
Arguments
name(
character(1))
The name of the network.module_generator(
function(pretrained, num_classes))
Function that generates the network.label(
character(1))
The label of the network.optimizer(
TorchOptimizer)
The optimizer to use for training.Per default,adam is used.loss(
TorchLoss)
The loss used to train the network.Per default,mse is used for regression andcross_entropy for classification.callbacks(
list()ofTorchCallbacks)
The callbacks. Must have unique ids.jittable(
logical(1))
Whether to use jitting.
Methodclone()
The objects of this class are cloneable with this method.
Usage
LearnerTorchVision$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
References
Krizhevsky, Alex, Sutskever, Ilya, Hinton, E. G (2017).“Imagenet classification with deep convolutional neural networks.”Communications of the ACM,60(6), 84–90.Sandler, Mark, Howard, Andrew, Zhu, Menglong, Zhmoginov, Andrey, Chen, Liang-Chieh (2018).“Mobilenetv2: Inverted residuals and linear bottlenecks.”InProceedings of the IEEE conference on computer vision and pattern recognition, 4510–4520.He, Kaiming, Zhang, Xiangyu, Ren, Shaoqing, Sun, Jian (2016).“Deep residual learning for image recognition.”InProceedings of the IEEE conference on computer vision and pattern recognition, 770–778.Simonyan, Karen, Zisserman, Andrew (2014).“Very deep convolutional networks for large-scale image recognition.”arXiv preprint arXiv:1409.1556.
Base Class for Torch Learners
Description
This base class provides the basic functionality for training and prediction of a neural network.All torch learners should inherit from this class.
Validation
To specify the validation data, you can set the$validate field of the Learner, which can be set to:
NULL: no validationratio: only proportion1 - ratioof the task is used for training andratiois used for validation."test"means that the"test"task of a resampling is used and is not possible when calling$train()manually."predefined": This will use the predefined$internal_valid_taskof amlr3::Task.
This validation data can also be used for early stopping, see the description of theLearner's parameters.
Saving a Learner
In order to save aLearnerTorch for later usage, it is necessary to call the$marshal() method on theLearnerbefore writing it to disk, as the object will otherwise not be saved correctly.After loading a marshaledLearnerTorch into R again, you then need to call$unmarshal() to transform itinto a useable state.
Early Stopping and Internal Tuning
In order to prevent overfitting, theLearnerTorch class allows to use early stopping via thepatienceandmin_delta parameters, see theLearner's parameters.When tuning aLearnerTorch it is also possible to combine the explicit tuning viamlr3tuningand theLearnerTorch's internal tuning of the epochs via early stopping.To do so, you just need to includeepochs = to_tune(upper = <upper>, internal = TRUE) in the search space,where<upper> is the maximally allowed number of epochs, and configure the early stopping.
Network Head and Target Encoding
Torch learners are expected to have the following output:
binary classification:
(batch_size, 1), representing the logits for the positive class.multiclass classification:
(batch_size, n_classes), representing the logits for all classes.regression:
(batch_size, 1)representing the response prediction.
Furthermore, the target encoding is expected to be as follows:
regression: The
numerictarget variable of aTaskRegris encoded as atorch_floatwith shapec(batch_size, 1).binary classification: The
factortarget variable of aTaskClassifis encoded as atorch_floatwith shape(batch_size, 1)where the positive class (Task$positive, whichis also ensured to be the first factor level) is1and the negative class is0.multi-class classification: The
factortarget variable of aTaskClassifis a label-encodedtorch_longwith shape(batch_size)where the label-encoding goes from1ton_classes.
Model
The Model is a list of class"learner_torch_model" with the following elements:
network:: The trainednetwork.optimizer:: The$state_dict()optimizer used to train the network.loss_fn:: The$state_dict()of theloss used to train the network.callbacks:: Thecallbacks used to train the network.seed:: The seed that was / is used for training and prediction.epochs:: How many epochs the model was trained for (early stopping).task_col_info:: Adata.table()containing information about the train-task.
Parameters
General:
The parameters of the optimizer, loss and callbacks,prefixed with"opt.","loss." and"cb.<callback id>." respectively, as well as:
epochs::integer(1)
The number of epochs.device::character(1)
The device. One of"auto","cpu", or"cuda"or other values defined inmlr_reflections$torch$devices.The value is initialized to"auto", which will select"cuda"if possible, then try"mps"and otherwisefall back to"cpu".num_threads::integer(1)
The number of threads for intraop pararallelization (ifdeviceis"cpu").This value is initialized to 1.num_interop_threads::integer(1)
The number of threads for intraop and interop pararallelization (ifdeviceis"cpu").This value is initialized to 1.Note that this can only be set once during a session and changing the value within an R session will raise a warning.seed::integer(1)or"random"orNULL
The torch seed that is used during training and prediction.This value is initialized to"random", which means that a random seed will be sampled at the beginning of thetraining phase. This seed (either set or randomly sampled) is available via$model$seedafter trainingand used during prediction.Note that by setting the seed during the training phase this will mean that by default (i.e. whenseedis"random"), clones of the learner will use a different seed.If set toNULL, no seeding will be done.tensor_dataset::logical(1)|"device"
Whether to load all batches at once at the beginning of training and stack them.This is initialized toFALSE.If set to"device", the device of the tensors will be set to the value ofdevice, whichcan avoid unnecessary moving of tensors between devices.When your dataset fits into memory this will make the loading of batches faster.Note that this should not be set for datasets that containlazy_tensors with random data augmentation,as this augmentation will only be applied once at the beginning of training.
Evaluation:
measures_train::Measureorlist()ofMeasures
Measures to be evaluated during training.measures_valid::Measureorlist()ofMeasures
Measures to be evaluated during validation.eval_freq::integer(1)
How often the train / validation predictions are evaluated usingmeasures_train/measures_valid.This is initialized to1.Note that the final model is always evaluated.
Early Stopping:
patience::integer(1)
This activates early stopping using the validation scores.If the performance of a model does not improve forpatienceevaluation steps, training is ended.Note that the final model is stored in the learner, not the best model.This is initialized to0, which means no early stopping.The first entry frommeasures_validis used as the metric.This also requires to specify the$validatefield of the Learner, as well asmeasures_valid.If this is set, the epoch after which no improvement was observed, can be accessed via the$internal_tuned_valuesfield of the learner.min_delta::double(1)
The minimum improvement threshold for early stopping.Is initialized to 0.
Dataloader:
batch_size::integer(1)
The batch size (required).shuffle::logical(1)
Whether to shuffle the instances in the dataset. This is initialized toTRUE,which differs from the default (FALSE).sampler::torch::sampler
Object that defines how the dataloader draw samples.batch_sampler::torch::sampler
Object that defines how the dataloader draws batches.num_workers::integer(1)
The number of workers for data loading (batches are loaded in parallel).The default is0, which means that data will be loaded in the main process.collate_fn::function
How to merge a list of samples to form a batch.pin_memory::logical(1)
Whether the dataloader copies tensors into CUDA pinned memory before returning them.drop_last::logical(1)
Whether to drop the last training batch in each epoch during training. Default isFALSE.timeout::numeric(1)
The timeout value for collecting a batch from workers.Negative values mean no timeout and the default is-1.worker_init_fn::function(id)
A function that receives the worker id (in[1, num_workers]) and is exectued after seedingon the worker but before data loading.worker_globals::list()|character()
When loading data in parallel, this allows to export globals to the workers.If this is a character vector, the objects in the global environment with those namesare copied to the workers.worker_packages::character()
Which packages to load on the workers.
Also seetorch::dataloder for more information.
Inheriting
There are no seperate classes for classification and regression to inherit from.Instead, thetask_type must be specified as a construction argument.Currently, only classification and regression are supported.
When inheriting from this class, one should overload the following methods:
.network(task, param_vals)
(Task,list()) ->nn_module
Construct atorch::nn_moduleobject for the given task and parameter values, i.e. the neural network thatis trained by the learner.Note that a specific output shape is expected from the returned network, see sectionNetwork Head and Target Encoding.You can useoutput_dim_for()to obtain the correct output dimension for a given task..ingress_tokens(task, param_vals)
(Task,list()) -> namedlist()withTorchIngressTokens
Create theTorchIngressTokens that are passed to thetask_datasetconstructor.The number of ingress tokens must correspond to the number of input parameters of the network.If there is more than one input, the names must correspond to the inputs of the network.Seeingress_num,ingress_categ, andingress_ltnsron how to easily create the correct tokens.For more flexibility, you can also directly implement the.dataset(task, param_vals)method,see below..dataset(task, param_vals)
(Task,list()) ->torch::dataset
Create the dataset for the task.Don't implement this if the.ingress_tokens()method is defined.The dataset must return a named list where:xis a list of torch tensors that are the input to the network.For networks with more than one input, the names must correspond to the inputs of the network.yis the target tensor..indexare the indices of the batch (integer()or atorch_int()).
For information on the expected target encoding of
y, see sectionNetwork Head and Target Encoding.Moreover, one needs to pay attention respect the row ids of the provided task.It is recommended to relu ontask_datasetfor creating thedataset.
It is also possible to overwrite the private.dataloader() method.This must respect the dataloader parameters from theParamSet.
.dataloader(dataset, param_vals)
(Task,list()) ->torch::dataloader
Create a dataloader from the task.Needs to respect at leastbatch_sizeandshuffle(otherwise predictions will be incorrectly ordered).
To change the predict types, it is possible to overwrite the method below:
.encode_prediction(predict_tensor, task)
(torch_tensor,Task) ->list()
Take in the raw predictions fromself$network(predict_tensor) and encode them into aformat that can be converted to validmlr3predictions usingmlr3::as_prediction_data().This method must takeself$predict_typeinto account.
While it is possible to add parameters by specifying theparam_set construction argument, it is currentlynot possible to remove existing parameters, i.e. those listed in sectionParameters.None of the parameters provided inparam_set can have an id that starts with"loss.","opt.", or "cb."', as these are preserved for the dynamically constructed parameters of the optimizer, the loss function,and the callbacks.
To perform additional input checks on the task, the private.check_train_task(task, param_vals) and.check_predict_task(task, param_vals) can be overwritten.These should returnTRUE if the input task is valid and otherwise a string with an error message.
For learners that have other construction arguments that should change the hash of a learner, it is requiredto implement the private$.additional_phash_input().
Super class
mlr3::Learner ->LearnerTorch
Active bindings
validateHow to construct the internal validation data. This parameter can be either
NULL,a ratio in $(0, 1)$,"test", or"predefined".loss(
TorchLoss)
The torch loss.optimizer(
TorchOptimizer)
The torch optimizer.callbacks(
list()ofTorchCallbacks)
List of torch callbacks.The ids will be set as the names.internal_valid_scoresRetrieves the internal validation scores as a named
list().Specify the$validatefield and themeasures_validparameter to configure this.ReturnsNULLif learner is not trained yet.internal_tuned_valuesWhen early stopping is active, this returns a named list with the early-stopped epochs,otherwise an empty list is returned.Returns
NULLif learner is not trained yet.marshaled(
logical(1))
Whether the learner is marshaled.network(
nn_module())
Shortcut forlearner$model$network.param_set(
ParamSet)
The parameter sethash(
character(1))
Hash (unique identifier) for this object.phash(
character(1))
Hash (unique identifier) for this partial object, excluding some componentswhich are varied systematically during tuning (parameter values).
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
LearnerTorch$new( id, task_type, param_set, properties = character(), man, label, feature_types, optimizer = NULL, loss = NULL, packages = character(), predict_types = NULL, callbacks = list(), jittable = FALSE)
Arguments
id(
character(1))
The id for of the new object.task_type(
character(1))
The task type.param_set(
ParamSetoralist())
Either a parameter set, or analist()containing different values of self,e.g.alist(private$.param_set1, private$.param_set2), from which aParamSetcollectionshould be created.properties(
character())
The properties of the object.Seemlr_reflections$learner_propertiesfor available values.man(
character(1))
String in the format[pkg]::[topic]pointing to a manual page for this object.The referenced help package can be opened via method$help().label(
character(1))
Label for the new instance.feature_types(
character())
The feature types.Seemlr_reflections$task_feature_typesfor available values,Additionally,"lazy_tensor"is supported.optimizer(
NULLorTorchOptimizer)
The optimizer to use for training.Defaults to adam.loss(
NULLorTorchLoss)
The loss to use for training.Defaults to MSE for regression and cross entropy for classification.packages(
character())
The R packages this object depends on.predict_types(
character())
The predict types.Seemlr_reflections$learner_predict_typesfor available values.For regression, the default is"response".For classification, this defaults to"response"and"prob".To deviate from the defaults, it is necessary to overwrite the private$.encode_prediction()method, see sectionInheriting.callbacks(
list()ofTorchCallbacks)
The callbacks to use for training.Defaults to an emptylist(), i.e. no callbacks.jittable(
logical(1))
Whether the model can be jit-traced. Default isFALSE.
Methodformat()
Helper for print outputs.
Usage
LearnerTorch$format(...)
Arguments
...(ignored).
Methodprint()
Prints the object.
Usage
LearnerTorch$print(...)
Arguments
...(any)
Currently unused.
Methodmarshal()
Marshal the learner.
Usage
LearnerTorch$marshal(...)
Arguments
...(any)
Additional parameters.
Returns
self
Methodunmarshal()
Unmarshal the learner.
Usage
LearnerTorch$unmarshal(...)
Arguments
...(any)
Additional parameters.
Returns
self
Methoddataset()
Create the dataset for a task.
Usage
LearnerTorch$dataset(task)
Arguments
taskTask
The task
Returns
Methodclone()
The objects of this class are cloneable with this method.
Usage
LearnerTorch$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Learner:mlr_learners.ft_transformer,mlr_learners.mlp,mlr_learners.module,mlr_learners.tab_resnet,mlr_learners.torch_featureless,mlr_learners_torch_image,mlr_learners_torch_model
Image Learner
Description
Base Class for Image Learners.The features are assumed to be a singlelazy_tensor column in RGB format.
Parameters
Parameters include those inherited fromLearnerTorch and theparam_set construction argument.
Super classes
mlr3::Learner ->mlr3torch::LearnerTorch ->LearnerTorchImage
Methods
Public methods
Inherited methods
mlr3::Learner$base_learner()mlr3::Learner$configure()mlr3::Learner$encapsulate()mlr3::Learner$help()mlr3::Learner$predict()mlr3::Learner$predict_newdata()mlr3::Learner$reset()mlr3::Learner$selected_features()mlr3::Learner$train()mlr3torch::LearnerTorch$dataset()mlr3torch::LearnerTorch$format()mlr3torch::LearnerTorch$marshal()mlr3torch::LearnerTorch$print()mlr3torch::LearnerTorch$unmarshal()
Methodnew()
Creates a new instance of thisR6 class.
Usage
LearnerTorchImage$new( id, task_type, param_set = ps(), label, optimizer = NULL, loss = NULL, callbacks = list(), packages, man, properties = NULL, predict_types = NULL, jittable = FALSE)
Arguments
id(
character(1))
The id for of the new object.task_type(
character(1))
The task type.param_set(
ParamSet)
The parameter set.label(
character(1))
Label for the new instance.optimizer(
TorchOptimizer)
The torch optimizer.loss(
TorchLoss)
The loss to use for training.callbacks(
list()ofTorchCallbacks)
The callbacks used during training.Must have unique ids.They are executed in the order in which they are providedpackages(
character())
The R packages this object depends on.man(
character(1))
String in the format[pkg]::[topic]pointing to a manual page for this object.The referenced help package can be opened via method$help().properties(
character())
The properties of the object.Seemlr_reflections$learner_propertiesfor available values.predict_types(
character())
The predict types.Seemlr_reflections$learner_predict_typesfor available values.jittable(
logical(1))
Whether the model can be jit-traced.
Methodclone()
The objects of this class are cloneable with this method.
Usage
LearnerTorchImage$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Learner:mlr_learners.ft_transformer,mlr_learners.mlp,mlr_learners.module,mlr_learners.tab_resnet,mlr_learners.torch_featureless,mlr_learners_torch,mlr_learners_torch_model
Learner Torch Model
Description
Create a torch learner from an instantiatednn_module().For classification, the output of the network must be the scores (before the softmax).
Parameters
SeeLearnerTorch
Super classes
mlr3::Learner ->mlr3torch::LearnerTorch ->LearnerTorchModel
Active bindings
ingress_tokens(named
list()withTorchIngressTokenorNULL)
The ingress tokens. Must be non-NULLwhen calling$train().
Methods
Public methods
Inherited methods
mlr3::Learner$base_learner()mlr3::Learner$configure()mlr3::Learner$encapsulate()mlr3::Learner$help()mlr3::Learner$predict()mlr3::Learner$predict_newdata()mlr3::Learner$reset()mlr3::Learner$selected_features()mlr3::Learner$train()mlr3torch::LearnerTorch$dataset()mlr3torch::LearnerTorch$format()mlr3torch::LearnerTorch$marshal()mlr3torch::LearnerTorch$print()mlr3torch::LearnerTorch$unmarshal()
Methodnew()
Creates a new instance of thisR6 class.
Usage
LearnerTorchModel$new( network = NULL, ingress_tokens = NULL, task_type, properties = NULL, optimizer = NULL, loss = NULL, callbacks = list(), packages = character(0), feature_types = NULL)
Arguments
network(
nn_module)
An instantiatednn_module. Is not cloned during construction.For classification, outputs must be the scores (before the softmax).ingress_tokens(
listofTorchIngressToken())
A list with ingress tokens that defines how the dataloader will be defined.task_type(
character(1))
The task type.properties(
NULLorcharacter())
The properties of the learner.Defaults to all available properties for the given task type.optimizer(
TorchOptimizer)
The torch optimizer.loss(
TorchLoss)
The loss to use for training.callbacks(
list()ofTorchCallbacks)
The callbacks used during training.Must have unique ids.They are executed in the order in which they are providedpackages(
character())
The R packages this object depends on.feature_types(
NULLorcharacter())
The feature types. Defaults to all available feature types.
Methodclone()
The objects of this class are cloneable with this method.
Usage
LearnerTorchModel$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Learner:mlr_learners.ft_transformer,mlr_learners.mlp,mlr_learners.module,mlr_learners.tab_resnet,mlr_learners.torch_featureless,mlr_learners_torch,mlr_learners_torch_image
Other Graph Network:ModelDescriptor(),TorchIngressToken(),mlr_pipeops_module,mlr_pipeops_torch,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,model_descriptor_to_learner(),model_descriptor_to_module(),model_descriptor_union(),nn_graph()
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)Center Crop Augmentation
Description
Callstorchvision::transform_center_crop,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("augment_center_crop"")Parameters
| Id | Type | Default | Levels |
| size | untyped | - | |
| stages | character | - | train, predict, both |
| affect_columns | untyped | selector_all() | |
Color Jitter Augmentation
Description
Callstorchvision::transform_color_jitter,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("augment_color_jitter"")Parameters
| Id | Type | Default | Levels | Range |
| brightness | numeric | 0 | [0, \infty) | |
| contrast | numeric | 0 | [0, \infty) | |
| saturation | numeric | 0 | [0, \infty) | |
| hue | numeric | 0 | [0, \infty) | |
| stages | character | - | train, predict, both | - |
| affect_columns | untyped | selector_all() | - | |
Crop Augmentation
Description
Callstorchvision::transform_crop,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("augment_crop"")Parameters
| Id | Type | Default | Levels | Range |
| top | integer | - | (-\infty, \infty) | |
| left | integer | - | (-\infty, \infty) | |
| height | integer | - | (-\infty, \infty) | |
| width | integer | - | (-\infty, \infty) | |
| stages | character | - | train, predict, both | - |
| affect_columns | untyped | selector_all() | - | |
Horizontal Flip Augmentation
Description
Callstorchvision::transform_hflip,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("augment_hflip"")Parameters
| Id | Type | Default | Levels |
| stages | character | - | train, predict, both |
| affect_columns | untyped | selector_all() | |
Random Affine Augmentation
Description
Callstorchvision::transform_random_affine,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("augment_random_affine"")Parameters
| Id | Type | Default | Levels | Range |
| degrees | untyped | - | - | |
| translate | untyped | NULL | - | |
| scale | untyped | NULL | - | |
| resample | integer | 0 | (-\infty, \infty) | |
| fillcolor | untyped | 0 | - | |
| stages | character | - | train, predict, both | - |
| affect_columns | untyped | selector_all() | - | |
Random Choice Augmentation
Description
Callstorchvision::transform_random_choice,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("augment_random_choice"")Parameters
| Id | Type | Default | Levels |
| transforms | untyped | - | |
| stages | character | - | train, predict, both |
| affect_columns | untyped | selector_all() | |
Random Crop Augmentation
Description
Callstorchvision::transform_random_crop,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("augment_random_crop"")Parameters
| Id | Type | Default | Levels |
| size | untyped | - | |
| padding | untyped | NULL | |
| pad_if_needed | logical | FALSE | TRUE, FALSE |
| fill | untyped | 0L | |
| padding_mode | character | constant | constant, edge, reflect, symmetric |
| stages | character | - | train, predict, both |
| affect_columns | untyped | selector_all() | |
Random Horizontal Flip Augmentation
Description
Callstorchvision::transform_random_horizontal_flip,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("augment_random_horizontal_flip"")Parameters
| Id | Type | Default | Levels | Range |
| p | numeric | 0.5 | [0, 1] | |
| stages | character | - | train, predict, both | - |
| affect_columns | untyped | selector_all() | - | |
Random Order Augmentation
Description
Callstorchvision::transform_random_order,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("augment_random_order"")Parameters
| Id | Type | Default | Levels |
| transforms | untyped | - | |
| stages | character | - | train, predict, both |
| affect_columns | untyped | selector_all() | |
Random Resized Crop Augmentation
Description
Callstorchvision::transform_random_resized_crop,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("augment_random_resized_crop"")Parameters
| Id | Type | Default | Levels | Range |
| size | untyped | - | - | |
| scale | untyped | c(0.08, 1) | - | |
| ratio | untyped | c(3/4, 4/3) | - | |
| interpolation | integer | 2 | [0, 3] | |
| stages | character | - | train, predict, both | - |
| affect_columns | untyped | selector_all() | - | |
Random Vertical Flip Augmentation
Description
Callstorchvision::transform_random_vertical_flip,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("augment_random_vertical_flip"")Parameters
| Id | Type | Default | Levels | Range |
| p | numeric | 0.5 | [0, 1] | |
| stages | character | - | train, predict, both | - |
| affect_columns | untyped | selector_all() | - | |
Resized Crop Augmentation
Description
Callstorchvision::transform_resized_crop,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("augment_resized_crop"")Parameters
| Id | Type | Default | Levels | Range |
| top | integer | - | (-\infty, \infty) | |
| left | integer | - | (-\infty, \infty) | |
| height | integer | - | (-\infty, \infty) | |
| width | integer | - | (-\infty, \infty) | |
| size | untyped | - | - | |
| interpolation | integer | 2 | [0, 3] | |
| stages | character | - | train, predict, both | - |
| affect_columns | untyped | selector_all() | - | |
Rotate Augmentation
Description
Callstorchvision::transform_rotate,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("augment_rotate"")Parameters
| Id | Type | Default | Levels | Range |
| angle | untyped | - | - | |
| resample | integer | 0 | (-\infty, \infty) | |
| expand | logical | FALSE | TRUE, FALSE | - |
| center | untyped | NULL | - | |
| fill | untyped | NULL | - | |
| stages | character | - | train, predict, both | - |
| affect_columns | untyped | selector_all() | - | |
Vertical Flip Augmentation
Description
Callstorchvision::transform_vflip,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("augment_vflip"")Parameters
| Id | Type | Default | Levels |
| stages | character | - | train, predict, both |
| affect_columns | untyped | selector_all() | |
Class for Torch Module Wrappers
Description
PipeOpModule wraps annn_module orfunction that is being called during thetrain phase of thismlr3pipelines::PipeOp. By doing so, this allows to assemblePipeOpModules in a computationalmlr3pipelines::Graph that represents either a neural network or a preprocessing graph of alazy_tensor.In most cases it is easier to create such a network by creating a graph that generates this graph.
In most cases it is easier to create such a network by creating a structurally related graph consistingof nodes of classPipeOpTorchIngress andPipeOpTorch. This graph will then generate the graph consistingofPipeOpModules as part of theModelDescriptor.
Input and Output Channels
The number and names of the input and output channels can be set during construction. They input and output"torch_tensor" during training, andNULL during prediction as the prediction phase currently serves nomeaningful purpose.
State
The state is the value calculated by the public methodshapes_out().
Parameters
No parameters.
Internals
During training, the wrappednn_module /function is called with the provided inputs in the order in whichthe channels are defined. Arguments arenot matched by name.
Super class
mlr3pipelines::PipeOp ->PipeOpModule
Public fields
module(
nn_module)
The torch module that is called during the training phase.
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpModule$new( id = "module", module = nn_identity(), inname = "input", outname = "output", param_vals = list(), packages = character(0))
Arguments
id(
character(1))
The id for of the new object.module(
nn_moduleorfunction())
The torch module or function that is being wrapped.inname(
character())
The names of the input channels.outname(
character())
The names of the output channels. If this parameter has length 1, the parametermodule mustreturn atensor. Otherwise it must return alist()of tensors of corresponding length.param_vals(named
list())
Parameter values to be set after construction.packages(
character())
The R packages this object depends on.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpModule$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Graph Network:ModelDescriptor(),TorchIngressToken(),mlr_learners_torch_model,mlr_pipeops_torch,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,model_descriptor_to_learner(),model_descriptor_to_module(),model_descriptor_union(),nn_graph()
Other PipeOp:mlr_pipeops_torch_callbacks,mlr_pipeops_torch_optimizer
Examples
## creating an PipeOpModule manually# one input and output channelpo_module = po("module", id = "linear", module = torch::nn_linear(10, 20), inname = "input", outname = "output")x = torch::torch_randn(16, 10)# This calls the forward function of the wrapped module.y = po_module$train(list(input = x))str(y)# multiple input and output channelsnn_custom = torch::nn_module("nn_custom", initialize = function(in_features, out_features) { self$lin1 = torch::nn_linear(in_features, out_features) self$lin2 = torch::nn_linear(in_features, out_features) }, forward = function(x, z) { list(out1 = self$lin1(x), out2 = torch::nnf_relu(self$lin2(z))) })module = nn_custom(3, 2)po_module = po("module", id = "custom", module = module, inname = c("x", "z"), outname = c("out1", "out2"))x = torch::torch_randn(1, 3)z = torch::torch_randn(1, 3)out = po_module$train(list(x = x, z = z))str(out)# How such a PipeOpModule is usually generatedgraph = po("torch_ingress_num") %>>% po("nn_linear", out_features = 10L)result = graph$train(tsk("iris"))# The PipeOpTorchLinear generates a PipeOpModule and adds it to a new (module) graphresult[[1]]$graphlinear_module = result[[1L]]$graph$pipeops$nn_linearlinear_moduleformalArgs(linear_module$module)linear_module$input$name# Constructing a PipeOpModule using a simple functionpo_add1 = po("module", id = "add_one", module = function(x) x + 1)input = list(torch_tensor(1))po_add1$train(input)$output1D Adaptive Average Pooling
Description
Applies a 1D adaptive average pooling over an input signal composed ofseveral input planes.
nn_module
Callsnn_adaptive_avg_pool1d() during training.
Parameters
output_size::integer(1)
The target output size. A single number.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchAdaptiveAvgPool ->PipeOpTorchAdaptiveAvgPool1D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchAdaptiveAvgPool1D$new( id = "nn_adaptive_avg_pool1d", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchAdaptiveAvgPool1D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_adaptive_avg_pool1d")pipeop# The available parameterspipeop$param_set2D Adaptive Average Pooling
Description
Applies a 2D adaptive average pooling over an input signal composed ofseveral input planes.
nn_module
Callsnn_adaptive_avg_pool2d() during training.
Parameters
output_size::integer()
The target output size. Can be a single number or a vector.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchAdaptiveAvgPool ->PipeOpTorchAdaptiveAvgPool2D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchAdaptiveAvgPool2D$new( id = "nn_adaptive_avg_pool2d", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchAdaptiveAvgPool2D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_adaptive_avg_pool2d")pipeop# The available parameterspipeop$param_set3D Adaptive Average Pooling
Description
Applies a 3D adaptive average pooling over an input signal composed ofseveral input planes.
nn_module
Callsnn_adaptive_avg_pool3d() during training.
Parameters
output_size::integer()
The target output size. Can be a single number or a vector.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchAdaptiveAvgPool ->PipeOpTorchAdaptiveAvgPool3D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchAdaptiveAvgPool3D$new( id = "nn_adaptive_avg_pool3d", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchAdaptiveAvgPool3D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_adaptive_avg_pool3d")pipeop# The available parameterspipeop$param_set1D Average Pooling
Description
Applies a 1D average pooling over an input signal composed of severalinput planes.
nn_module
Callsnn_avg_pool1d() during training.
Parameters
kernel_size:: (integer())
The size of the window. Can be a single number or a vector.stride::integer()
The stride of the window. Can be a single number or a vector. Default:kernel_size.padding::integer()
Implicit zero paddings on both sides of the input. Can be a single number or a vector. Default: 0.ceil_mode::integer()
WhenTRUE, will use ceil instead of floor to compute the output shape. Default:FALSE.count_include_pad::logical(1)
WhenTRUE, will include the zero-padding in the averaging calculation. Default:TRUE.divisor_override::logical(1)
If specified, it will be used as divisor, otherwise size of the pooling region will be used. Default: NULL.Only available for dimension greater than 1.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchAvgPool ->PipeOpTorchAvgPool1D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchAvgPool1D$new(id = "nn_avg_pool1d", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchAvgPool1D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_avg_pool1d")pipeop# The available parameterspipeop$param_set2D Average Pooling
Description
Applies 2D average-pooling operation inkH * kW regions by step sizesH * sW steps. The number of output features is equal to the number ofinput planes.
nn_module
Callsnn_avg_pool2d() during training.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Parameters
kernel_size:: (integer())
The size of the window. Can be a single number or a vector.stride::integer()
The stride of the window. Can be a single number or a vector. Default:kernel_size.padding::integer()
Implicit zero paddings on both sides of the input. Can be a single number or a vector. Default: 0.ceil_mode::integer()
WhenTRUE, will use ceil instead of floor to compute the output shape. Default:FALSE.count_include_pad::logical(1)
WhenTRUE, will include the zero-padding in the averaging calculation. Default:TRUE.divisor_override::logical(1)
If specified, it will be used as divisor, otherwise size of the pooling region will be used. Default: NULL.Only available for dimension greater than 1.
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchAvgPool ->PipeOpTorchAvgPool2D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchAvgPool2D$new(id = "nn_avg_pool2d", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchAvgPool2D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_avg_pool2d")pipeop# The available parameterspipeop$param_set3D Average Pooling
Description
Applies 3D average-pooling operation inkT * kH * kW regions by stepsizesT * sH * sW steps. The number of output features is equal to\lfloor \frac{ \mbox{input planes} }{sT} \rfloor.
Internals
Callsnn_avg_pool3d() during training.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Parameters
kernel_size:: (integer())
The size of the window. Can be a single number or a vector.stride::integer()
The stride of the window. Can be a single number or a vector. Default:kernel_size.padding::integer()
Implicit zero paddings on both sides of the input. Can be a single number or a vector. Default: 0.ceil_mode::integer()
WhenTRUE, will use ceil instead of floor to compute the output shape. Default:FALSE.count_include_pad::logical(1)
WhenTRUE, will include the zero-padding in the averaging calculation. Default:TRUE.divisor_override::logical(1)
If specified, it will be used as divisor, otherwise size of the pooling region will be used. Default: NULL.Only available for dimension greater than 1.
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchAvgPool ->PipeOpTorchAvgPool3D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchAvgPool3D$new(id = "nn_avg_pool3d", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchAvgPool3D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_avg_pool3d")pipeop# The available parameterspipeop$param_set1D Batch Normalization
Description
Applies Batch Normalization for each channel across a batch of data.
nn_module
Callstorch::nn_batch_norm1d().The parameternum_features is inferred as the second dimension of the input shape.
Parameters
eps::numeric(1)
A value added to the denominator for numerical stability. Default:1e-5.momentum::numeric(1)
The value used for the running_mean and running_var computation. Can be set toNULLfor cumulative moving average(i.e. simple average). Default: 0.1affine::logical(1)
a boolean value that when set toTRUE, this module has learnable affine parameters. Default:TRUEtrack_running_stats::logical(1)
a boolean value that when set toTRUE, this module tracks the running mean and variance, and when set toFALSE,this module does not track such statistics and always uses batch statistics in both training and eval modes.Default:TRUE
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchBatchNorm ->PipeOpTorchBatchNorm1D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchBatchNorm1D$new(id = "nn_batch_norm1d", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchBatchNorm1D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_batch_norm1d")pipeop# The available parameterspipeop$param_set2D Batch Normalization
Description
Applies Batch Normalization for each channel across a batch of data.
nn_module
Callstorch::nn_batch_norm2d().The parameternum_features is inferred as the second dimension of the input shape.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Parameters
eps::numeric(1)
A value added to the denominator for numerical stability. Default:1e-5.momentum::numeric(1)
The value used for the running_mean and running_var computation. Can be set toNULLfor cumulative moving average(i.e. simple average). Default: 0.1affine::logical(1)
a boolean value that when set toTRUE, this module has learnable affine parameters. Default:TRUEtrack_running_stats::logical(1)
a boolean value that when set toTRUE, this module tracks the running mean and variance, and when set toFALSE,this module does not track such statistics and always uses batch statistics in both training and eval modes.Default:TRUE
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchBatchNorm ->PipeOpTorchBatchNorm2D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchBatchNorm2D$new(id = "nn_batch_norm2d", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchBatchNorm2D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_batch_norm2d")pipeop# The available parameterspipeop$param_set3D Batch Normalization
Description
Applies Batch Normalization for each channel across a batch of data.
nn_module
Callstorch::nn_batch_norm3d().The parameternum_features is inferred as the second dimension of the input shape.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Parameters
eps::numeric(1)
A value added to the denominator for numerical stability. Default:1e-5.momentum::numeric(1)
The value used for the running_mean and running_var computation. Can be set toNULLfor cumulative moving average(i.e. simple average). Default: 0.1affine::logical(1)
a boolean value that when set toTRUE, this module has learnable affine parameters. Default:TRUEtrack_running_stats::logical(1)
a boolean value that when set toTRUE, this module tracks the running mean and variance, and when set toFALSE,this module does not track such statistics and always uses batch statistics in both training and eval modes.Default:TRUE
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchBatchNorm ->PipeOpTorchBatchNorm3D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchBatchNorm3D$new(id = "nn_batch_norm3d", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchBatchNorm3D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_batch_norm3d")pipeop# The available parameterspipeop$param_setBlock Repetition
Description
Repeat a blockn_blocks times by concatenating it with itself (via%>>%).
Naming
For the generated module graph, the IDs of the modules are generated by prefixing theIDs of then_blocks layers with the ID of thePipeOpTorchBlock and postfixing them with__<layer>.
Parameters
The parameters available for the providedblock, as well as
n_blocks::integer(1)
How often to repeat the block.trafo::function(i, param_vals, param_set) -> list()
A function that allows to transform the parameters vaues of each layer (block).Here,i::integer(1)
is the index of the layer, ranging from1ton_blocks.param_vals:: namedlist()
are the parameter values of the layeri.param_set::ParamSet
is the parameter set of the wholePipeOpTorchBlock.
The function must return the modified parameter values for the given layer.This, e.g., allows for special behavior of the first or last layer.
Input and Output Channels
ThePipeOp sets its input and output channels to those from theblock (Graph)it received during construction.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchBlock
Active bindings
block(
Graph)
The neural network segment that is repeated by thisPipeOp.
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchBlock$new(block, id = "nn_block", param_vals = list())
Arguments
block(
Graph)
A graph consisting primarily ofPipeOpTorchobjects that is to berepeated.id(
character(1))
The id for of the new object.param_vals(named
list())
Parameter values to be set after construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchBlock$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# repeat a simple linear layer with ReLU activation 3 times, but set the bias for the last# layer to `FALSE`block = nn("linear") %>>% nn("relu")blocks = nn("block", block, linear.out_features = 10L, linear.bias = TRUE, n_blocks = 3, trafo = function(i, param_vals, param_set) { if (i == param_set$get_values()$n_blocks) { param_vals$linear.bias = FALSE } param_vals })graph = po("torch_ingress_num") %>>% blocks %>>% nn("head")md = graph$train(tsk("iris"))[[1L]]network = model_descriptor_to_module(md)networkCELU Activation Function
Description
Applies element-wise,CELU(x) = max(0,x) + min(0, \alpha * (exp(x \alpha) - 1)).
nn_module
Callstorch::nn_celu() when trained.
Parameters
alpha::numeric(1)
The alpha value for the ELU formulation. Default: 1.0inplace::logical(1)
Whether to do the operation in-place. Default:FALSE.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchCELU
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchCELU$new(id = "nn_celu", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchCELU$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_celu")pipeop# The available parameterspipeop$param_set1D Convolution
Description
Applies a 1D convolution over an input signal composed of several inputplanes.
nn_module
Callstorch::nn_conv1d() when trained.The paramterin_channels is inferred from the second dimension of the input tensor.
Parameters
out_channels::integer(1)
Number of channels produced by the convolution.kernel_size::integer()
Size of the convolving kernel.stride::integer()
Stride of the convolution. The default is 1.padding::integer()dilation * (kernel_size - 1) - paddingzero-padding will be added to both sides of the input. Default: 0.groups::integer()
Number of blocked connections from input channels to output channels. Default: 1bias::logical(1)
IfTRUE, adds a learnable bias to the output. Default:TRUE.dilation::integer()
Spacing between kernel elements. Default: 1.padding_mode::character(1)
The padding mode. One of"zeros","reflect","replicate", or"circular". Default is"zeros".
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchConv ->PipeOpTorchConv1D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchConv1D$new(id = "nn_conv1d", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchConv1D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_conv1d", kernel_size = 10, out_channels = 1)pipeop# The available parameterspipeop$param_set2D Convolution
Description
Applies a 2D convolution over an input image composed of several inputplanes.
nn_module
Callstorch::nn_conv2d() when trained.The paramterin_channels is inferred from the second dimension of the input tensor.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Parameters
out_channels::integer(1)
Number of channels produced by the convolution.kernel_size::integer()
Size of the convolving kernel.stride::integer()
Stride of the convolution. The default is 1.padding::integer()dilation * (kernel_size - 1) - paddingzero-padding will be added to both sides of the input. Default: 0.groups::integer()
Number of blocked connections from input channels to output channels. Default: 1bias::logical(1)
IfTRUE, adds a learnable bias to the output. Default:TRUE.dilation::integer()
Spacing between kernel elements. Default: 1.padding_mode::character(1)
The padding mode. One of"zeros","reflect","replicate", or"circular". Default is"zeros".
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchConv ->PipeOpTorchConv2D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchConv2D$new(id = "nn_conv2d", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchConv2D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_conv2d", kernel_size = 10, out_channels = 1)pipeop# The available parameterspipeop$param_set3D Convolution
Description
Applies a 3D convolution over an input image composed of several inputplanes.
nn_module
Callstorch::nn_conv3d() when trained.The paramterin_channels is inferred from the second dimension of the input tensor.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Parameters
out_channels::integer(1)
Number of channels produced by the convolution.kernel_size::integer()
Size of the convolving kernel.stride::integer()
Stride of the convolution. The default is 1.padding::integer()dilation * (kernel_size - 1) - paddingzero-padding will be added to both sides of the input. Default: 0.groups::integer()
Number of blocked connections from input channels to output channels. Default: 1bias::logical(1)
IfTRUE, adds a learnable bias to the output. Default:TRUE.dilation::integer()
Spacing between kernel elements. Default: 1.padding_mode::character(1)
The padding mode. One of"zeros","reflect","replicate", or"circular". Default is"zeros".
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchConv ->PipeOpTorchConv3D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchConv3D$new(id = "nn_conv3d", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchConv3D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_conv3d", kernel_size = 10, out_channels = 1)pipeop# The available parameterspipeop$param_setTranspose 1D Convolution
Description
Applies a 1D transposed convolution operator over an input signalcomposed of several input planes, sometimes also called "deconvolution".
nn_module
Callsnn_conv_transpose1d.The parameterin_channels is inferred as the second dimension of the input tensor.
Parameters
out_channels::integer(1)
Number of output channels produce by the convolution.kernel_size::integer()
Size of the convolving kernel.stride::integer()
Stride of the convolution. Default: 1.padding:: integer()\cr dilation * (kernel_size - 1) - padding' zero-padding will be added to both sides of the input. Default: 0.output_padding::integer()
Additional size added to one side of the output shape. Default: 0.groups::integer()
Number of blocked connections from input channels to output channels. Default: 1bias::logical(1)
IfTrue, adds a learnable bias to the output. Default:TRUE.dilation::integer()
Spacing between kernel elements. Default: 1.padding_mode::character(1)
The padding mode. One of"zeros","reflect","replicate", or"circular". Default is"zeros".
State
The state is the value calculated by the public method$shapes_out().
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchConvTranspose ->PipeOpTorchConvTranspose1D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchConvTranspose1D$new(id = "nn_conv_transpose1d", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchConvTranspose1D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_conv_transpose1d", kernel_size = 3, out_channels = 2)pipeop# The available parameterspipeop$param_setTranspose 2D Convolution
Description
Applies a 2D transposed convolution operator over an input imagecomposed of several input planes, sometimes also called "deconvolution".
nn_module
Callsnn_conv_transpose2d.The parameterin_channels is inferred as the second dimension of the input tensor.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Parameters
out_channels::integer(1)
Number of output channels produce by the convolution.kernel_size::integer()
Size of the convolving kernel.stride::integer()
Stride of the convolution. Default: 1.padding:: integer()\cr dilation * (kernel_size - 1) - padding' zero-padding will be added to both sides of the input. Default: 0.output_padding::integer()
Additional size added to one side of the output shape. Default: 0.groups::integer()
Number of blocked connections from input channels to output channels. Default: 1bias::logical(1)
IfTrue, adds a learnable bias to the output. Default:TRUE.dilation::integer()
Spacing between kernel elements. Default: 1.padding_mode::character(1)
The padding mode. One of"zeros","reflect","replicate", or"circular". Default is"zeros".
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchConvTranspose ->PipeOpTorchConvTranspose2D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchConvTranspose2D$new(id = "nn_conv_transpose2d", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchConvTranspose2D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_conv_transpose2d", kernel_size = 3, out_channels = 2)pipeop# The available parameterspipeop$param_setTranspose 3D Convolution
Description
Applies a 3D transposed convolution operator over an input imagecomposed of several input planes, sometimes also called "deconvolution"
nn_module
Callsnn_conv_transpose3d.The parameterin_channels is inferred as the second dimension of the input tensor.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Parameters
out_channels::integer(1)
Number of output channels produce by the convolution.kernel_size::integer()
Size of the convolving kernel.stride::integer()
Stride of the convolution. Default: 1.padding:: integer()\cr dilation * (kernel_size - 1) - padding' zero-padding will be added to both sides of the input. Default: 0.output_padding::integer()
Additional size added to one side of the output shape. Default: 0.groups::integer()
Number of blocked connections from input channels to output channels. Default: 1bias::logical(1)
IfTrue, adds a learnable bias to the output. Default:TRUE.dilation::integer()
Spacing between kernel elements. Default: 1.padding_mode::character(1)
The padding mode. One of"zeros","reflect","replicate", or"circular". Default is"zeros".
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchConvTranspose ->PipeOpTorchConvTranspose3D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchConvTranspose3D$new(id = "nn_conv_transpose3d", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchConvTranspose3D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_conv_transpose3d", kernel_size = 3, out_channels = 2)pipeop# The available parameterspipeop$param_setDropout
Description
During training, randomly zeroes some of the elements of the inputtensor with probabilityp using samples from a Bernoullidistribution.
nn_module
Callstorch::nn_dropout() when trained.
Parameters
p::numeric(1)
Probability of an element to be zeroed. Default: 0.5.inplace::logical(1)
If set toTRUE, will do this operation in-place. Default:FALSE.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchDropout
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchDropout$new(id = "nn_dropout", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchDropout$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_dropout")pipeop# The available parameterspipeop$param_setELU Activation Function
Description
Applies element-wise,
ELU(x) = max(0,x) + min(0, \alpha * (exp(x) - 1))
.
nn_module
Callstorch::nn_elu() when trained.
Parameters
alpha::numeric(1)
The alpha value for the ELU formulation. Default: 1.0inplace::logical(1)
Whether to do the operation in-place. Default:FALSE.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchELU
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchELU$new(id = "nn_elu", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchELU$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_elu")pipeop# The available parameterspipeop$param_setFlattens a Tensor
Description
For use withnn_sequential.
nn_module
Callstorch::nn_flatten() when trained.
Parameters
start_dim ::integer(1)
At wich dimension to start flattening. Default is 2.end_dim ::integer(1)
At wich dimension to stop flattening. Default is -1.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchFlatten
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchFlatten$new(id = "nn_flatten", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchFlatten$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_flatten")pipeop# The available parameterspipeop$param_setCustom Function
Description
Applies a user-supplied function to a tensor.
Parameters
By default, these are inferred as all but the first arguments of the functionfn.It is also possible to specify these more explicitly via theparam_set constructor argument.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchFn
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchFn$new( fn, id = "nn_fn", param_vals = list(), param_set = NULL, shapes_out = NULL)
Arguments
fn(
function)
The function to be applied. Takes atorchtensor as first argument and returns atorchtensor.id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.param_set(
ParamSetorNULL)
A ParamSet wrapping the arguments tofn.If omitted, then the ParamSet for this PipeOp will be inferred from the function signature.shapes_out(
functionorNULL)
A function that computes the output shapes of thefn. SeePipeOpTorch's.shapes_out()method for details on the parameters,andPipeOpTaskPreprocTorch for details on how the shapes are inferred whenthis parameter isNULL.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchFn$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
custom_fn = function(x, a) x / aobj = po("nn_fn", fn = custom_fn, a = 2)obj$param_setgraph = po("torch_ingress_ltnsr") %>>% objtask = tsk("lazy_iris")$filter(1)tnsr = materialize(task$data()$x)[[1]]md_trained = graph$train(task)trained = md_trained[[1]]$graph$train(tnsr)trained[[1]]custom_fn(tnsr, a = 2)CLS Token for FT-Transformer
Description
Concatenates a CLS token to the input as the last feature.The input shape is expected to be(batch, n_features, d_token) and the output shape is(batch, n_features + 1, d_token).
This is used in theLearnerTorchFTTransformer.
nn_module
Callsnn_ft_cls() when trained.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchFTCLS
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchFTCLS$new(id = "nn_ft_cls", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchFTCLS$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_ft_cls")pipeop# The available parameterspipeop$param_setSingle Transformer Block for the FT-Transformer
Description
A transformer block consisting of a multi-head self-attention mechanism followed by a feed-forwardnetwork.
This is used inLearnerTorchFTTransformer.
nn_module
Callsnn_ft_transformer_block() when trained.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchFTTransformerBlock
Methods
Public methods
Inherited methods
Methodnew()
Create a new instance of thisR6 class.
Usage
PipeOpTorchFTTransformerBlock$new( id = "nn_ft_transformer_block", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchFTTransformerBlock$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_ft_transformer_block")pipeop# The available parameterspipeop$param_setGeGLU Activation Function
Description
Gaussian Error Linear Unit Gated Linear Unit (GeGLU) activation function, seenn_geglu for details.
Parameters
No parameters.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchGeGLU
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchGeGLU$new(id = "nn_geglu", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchGeGLU$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_geglu")pipeop# The available parameterspipeop$param_setGELU Activation Function
Description
Gelu
nn_module
Callstorch::nn_gelu() when trained.
Parameters
approximate::character(1)
Whether to use an approximation algorithm. Default is"none".
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchGELU
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchGELU$new(id = "nn_gelu", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchGELU$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_gelu")pipeop# The available parameterspipeop$param_setGLU Activation Function
Description
The gated linear unit. Computes:
nn_module
Callstorch::nn_glu() when trained.
Parameters
dim::integer(1)
Dimension on which to split the input. Default: -1
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchGLU
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchGLU$new(id = "nn_glu", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchGLU$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_glu")pipeop# The available parameterspipeop$param_setHard Shrink Activation Function
Description
Applies the hard shrinkage function element-wise
nn_module
Callstorch::nn_hardshrink() when trained.
Parameters
lambd::numeric(1)
The lambda value for the Hardshrink formulation formulation. Default 0.5.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchHardShrink
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchHardShrink$new(id = "nn_hardshrink", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchHardShrink$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_hardshrink")pipeop# The available parameterspipeop$param_setHard Sigmoid Activation Function
Description
Applies the element-wise function\mbox{Hardsigmoid}(x) = \frac{ReLU6(x + 3)}{6}
nn_module
Callstorch::nn_hardsigmoid() when trained.
Parameters
No parameters.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchHardSigmoid
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchHardSigmoid$new(id = "nn_hardsigmoid", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchHardSigmoid$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_hardsigmoid")pipeop# The available parameterspipeop$param_setHard Tanh Activation Function
Description
Applies the HardTanh function element-wise.
nn_module
Callstorch::nn_hardtanh() when trained.
Parameters
min_val::numeric(1)
Minimum value of the linear region range. Default: -1.max_val::numeric(1)
Maximum value of the linear region range. Default: 1.inplace::logical(1)
Can optionally do the operation in-place. Default:FALSE.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchHardTanh
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchHardTanh$new(id = "nn_hardtanh", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchHardTanh$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_hardtanh")pipeop# The available parameterspipeop$param_setOutput Head
Description
Output head for classification and regresssion.
Details
When the method$shapes_out() does not have access to the task, it returnsc(NA, NA).When thisPipeOp is trained however, the model descriptor has the correct output shape.
nn_module
Callstorch::nn_linear() with the input and output features inferred from the input shape / task.For
binary classification, the output dimension is 1.
multiclass classification, the output dimension is the number of classes.
regression, the output dimension is 1.
Parameters
bias::logical(1)
Whether to use a bias. Default isTRUE.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchHead
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchHead$new(id = "nn_head", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchHead$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_head")pipeop# The available parameterspipeop$param_setIdentity Layer
Description
A placeholder identity operator that is argument-insensitive.
nn_module
Callstorch::nn_identity() when trained, which passes the input unchanged to the output.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchIdentity
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchIdentity$new(id = "nn_identity", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchIdentity$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_identity")pipeop# The available parameterspipeop$param_setLayer Normalization
Description
Applies Layer Normalization for last certain number of dimensions.
nn_module
Callstorch::nn_layer_norm() when trained.The parameternormalized_shape is inferred as the dimensions of the lastdims dimensions of the input shape.
Parameters
dims::integer(1)
The number of dimensions over which will be normalized (starting from the last dimension).elementwise_affine::logical(1)
Whether to learn affine-linear parameters initialized to1for weights and to0for biases.The default isTRUE.eps::numeric(1)
A value added to the denominator for numerical stability.
State
The state is the value calculated by the public method$shapes_out().
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchLayerNorm
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchLayerNorm$new(id = "nn_layer_norm", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchLayerNorm$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_layer_norm", dims = 1)pipeop# The available parameterspipeop$param_setLeaky ReLU Activation Function
Description
Applies element-wise,LeakyReLU(x) = max(0, x) + negative_slope * min(0, x)
nn_module
Callstorch::nn_leaky_relu() when trained.
Parameters
negative_slope::numeric(1)
Controls the angle of the negative slope. Default: 1e-2.inplace::logical(1)
Can optionally do the operation in-place. Default:FALSE.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchLeakyReLU
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchLeakyReLU$new(id = "nn_leaky_relu", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchLeakyReLU$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_leaky_relu")pipeop# The available parameterspipeop$param_setLinear Layer
Description
Applies a linear transformation to the incoming data:y = xA^T + b.
nn_module
Callstorch::nn_linear() when trained where the parameterin_features is inferred as the secondto last dimension of the input tensor.
Parameters
out_features::integer(1)
The output features of the linear layer.bias::logical(1)
Whether to use a bias.Default isTRUE.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchLinear
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchLinear$new(id = "nn_linear", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchLinear$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_linear", out_features = 10)pipeop# The available parameterspipeop$param_setLog Sigmoid Activation Function
Description
Applies element-wiseLogSigmoid(x_i) = log(\frac{1}{1 + exp(-x_i)})
nn_module
Callstorch::nn_log_sigmoid() when trained.
Parameters
No parameters.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchLogSigmoid
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchLogSigmoid$new(id = "nn_log_sigmoid", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchLogSigmoid$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_log_sigmoid")pipeop# The available parameterspipeop$param_set1D Max Pooling
Description
Applies a 1D max pooling over an input signal composed of several inputplanes.
nn_module
Callstorch::nn_max_pool1d() during training.
Parameters
kernel_size::integer()
The size of the window. Can be single number or a vector.stride:: (integer(1))
The stride of the window. Can be a single number or a vector. Default:kernel_sizepadding::integer()
Implicit zero paddings on both sides of the input. Can be a single number or a tuple (padW,). Default: 0dilation::integer()
Controls the spacing between the kernel points; also known as the a trous algorithm. Default: 1ceil_mode::logical(1)
When True, will use ceil instead of floor to compute the output shape. Default:FALSE
Input and Output Channels
Ifreturn_indices isFALSE during construction, there is one input channel 'input' and one output channel 'output'.Ifreturn_indices isTRUE, there are two output channels 'output' and 'indices'.For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchMaxPool ->PipeOpTorchMaxPool1D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchMaxPool1D$new( id = "nn_max_pool1d", return_indices = FALSE, param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.return_indices(
logical(1))
Whether to return the indices.If this isTRUE, there are two output channels"output"and"indices".param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchMaxPool1D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_max_pool1d")pipeop# The available parameterspipeop$param_set2D Max Pooling
Description
Applies a 2D max pooling over an input signal composed of several inputplanes.
nn_module
Callstorch::nn_max_pool2d() during training.
State
The state is the value calculated by the public method$shapes_out().
Parameters
kernel_size::integer()
The size of the window. Can be single number or a vector.stride:: (integer(1))
The stride of the window. Can be a single number or a vector. Default:kernel_sizepadding::integer()
Implicit zero paddings on both sides of the input. Can be a single number or a tuple (padW,). Default: 0dilation::integer()
Controls the spacing between the kernel points; also known as the a trous algorithm. Default: 1ceil_mode::logical(1)
When True, will use ceil instead of floor to compute the output shape. Default:FALSE
Input and Output Channels
Ifreturn_indices isFALSE during construction, there is one input channel 'input' and one output channel 'output'.Ifreturn_indices isTRUE, there are two output channels 'output' and 'indices'.For an explanation seePipeOpTorch.
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchMaxPool ->PipeOpTorchMaxPool2D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchMaxPool2D$new( id = "nn_max_pool2d", return_indices = FALSE, param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.return_indices(
logical(1))
Whether to return the indices.If this isTRUE, there are two output channels"output"and"indices".param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchMaxPool2D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_max_pool2d")pipeop# The available parameterspipeop$param_set3D Max Pooling
Description
Applies a 3D max pooling over an input signal composed of several inputplanes.
nn_module
Callstorch::nn_max_pool3d() during training.
State
The state is the value calculated by the public method$shapes_out().
Parameters
kernel_size::integer()
The size of the window. Can be single number or a vector.stride:: (integer(1))
The stride of the window. Can be a single number or a vector. Default:kernel_sizepadding::integer()
Implicit zero paddings on both sides of the input. Can be a single number or a tuple (padW,). Default: 0dilation::integer()
Controls the spacing between the kernel points; also known as the a trous algorithm. Default: 1ceil_mode::logical(1)
When True, will use ceil instead of floor to compute the output shape. Default:FALSE
Input and Output Channels
Ifreturn_indices isFALSE during construction, there is one input channel 'input' and one output channel 'output'.Ifreturn_indices isTRUE, there are two output channels 'output' and 'indices'.For an explanation seePipeOpTorch.
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchMaxPool ->PipeOpTorchMaxPool3D
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchMaxPool3D$new( id = "nn_max_pool3d", return_indices = FALSE, param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.return_indices(
logical(1))
Whether to return the indices.If this isTRUE, there are two output channels"output"and"indices".param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchMaxPool3D$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_max_pool3d")pipeop# The available parameterspipeop$param_setMerge Operation
Description
Base class for merge operations such as addition (PipeOpTorchMergeSum), multiplication(PipeOpTorchMergeProd or concatenation (PipeOpTorchMergeCat).
Parameters
See the respective child class.
State
The state is the value calculated by the public methodshapes_out().
Input and Output Channels
PipeOpTorchMerges has either avararg input channel if the constructor argumentinnum is not set, orinput channels"input1", ...,"input<innum>". There is one output channel"output".For an explanation seePipeOpTorch.
Internals
Per default, theprivate$.shapes_out() method outputs the broadcasted tensors. There are two things to be aware:
NAs are assumed to batch (this should almost always be the batch size in the first dimension).Tensors are expected to have the same number of dimensions, i.e. missing dimensions are not filled with 1s.The reason is again that the first dimension should be the batch dimension.This private method can be overwritten by
PipeOpTorchs inheriting from this class.
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchMerge
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchMerge$new( id, module_generator, param_set = ps(), innum = 0, param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.module_generator(
nn_module_generator)
The torch module generator.param_set(
ParamSet)
The parameter set.innum(
integer(1))
The number of inputs. Default is 0 which means there is onevararg input channel.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchMerge$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Merge by Concatenation
Description
Concatenates multiple tensors on a given dimension.No broadcasting rules are applied here, you must reshape the tensors before to have the same shape.
nn_module
Callsnn_merge_cat() when trained.
Parameters
dim::integer(1)
The dimension along which to concatenate the tensors. The default is -1, i.e., the last dimension.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
PipeOpTorchMerges has either avararg input channel if the constructor argumentinnum is not set, orinput channels"input1", ...,"input<innum>". There is one output channel"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchMerge ->PipeOpTorchMergeCat
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchMergeCat$new(id = "nn_merge_cat", innum = 0, param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.innum(
integer(1))
The number of inputs. Default is 0 which means there is onevararg input channel.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodspeak()
What does the cat say?
Usage
PipeOpTorchMergeCat$speak()
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchMergeCat$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_merge_cat")pipeop# The available parameterspipeop$param_setMerge by Product
Description
Calculates the product of all input tensors.
nn_module
Callsnn_merge_prod() when trained.
Parameters
No parameters.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
PipeOpTorchMerges has either avararg input channel if the constructor argumentinnum is not set, orinput channels"input1", ...,"input<innum>". There is one output channel"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchMerge ->PipeOpTorchMergeProd
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchMergeProd$new(id = "nn_merge_prod", innum = 0, param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.innum(
integer(1))
The number of inputs. Default is 0 which means there is onevararg input channel.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchMergeProd$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_merge_prod")pipeop# The available parameterspipeop$param_setMerge by Summation
Description
Calculates the sum of all input tensors.
nn_module
Callsnn_merge_sum() when trained.
Parameters
No parameters.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
PipeOpTorchMerges has either avararg input channel if the constructor argumentinnum is not set, orinput channels"input1", ...,"input<innum>". There is one output channel"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->mlr3torch::PipeOpTorchMerge ->PipeOpTorchMergeSum
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchMergeSum$new(id = "nn_merge_sum", innum = 0, param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.innum(
integer(1))
The number of inputs. Default is 0 which means there is onevararg input channel.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchMergeSum$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_merge_sum")pipeop# The available parameterspipeop$param_setPReLU Activation Function
Description
Applies element-wise the functionPReLU(x) = max(0,x) + weight * min(0,x)where weight is a learnable parameter.
nn_module
Callstorch::nn_prelu() when trained.
Parameters
num_parameters::integer(1):Number of a to learn. Although it takes an int as input, there is only two values are legitimate: 1, or thenumber of channels at input. Default: 1.init::numeric(1)
TThe initial value of a. Default: 0.25.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchPReLU
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchPReLU$new(id = "nn_prelu", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchPReLU$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_prelu")pipeop# The available parameterspipeop$param_setReGLU Activation Function
Description
Rectified Gated Linear Unit (ReGLU) activation function.Seenn_reglu for details.
Parameters
No parameters.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchReGLU
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchReGLU$new(id = "nn_reglu", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchReGLU$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_reglu")pipeop# The available parameterspipeop$param_setReLU Activation Function
Description
Applies the rectified linear unit function element-wise.
nn_module
Callstorch::nn_relu() when trained.
Parameters
inplace::logical(1)
Whether to do the operation in-place. Default:FALSE.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchReLU
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchReLU$new(id = "nn_relu", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchReLU$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_relu")pipeop# The available parameterspipeop$param_setReLU6 Activation Function
Description
Applies the element-wise functionReLU6(x) = min(max(0,x), 6).
nn_module
Callstorch::nn_relu6() when trained.
Parameters
inplace::logical(1)
Whether to do the operation in-place. Default:FALSE.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchReLU6
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchReLU6$new(id = "nn_relu6", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchReLU6$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_relu6")pipeop# The available parameterspipeop$param_setReshape a Tensor
Description
Reshape a tensor to the given shape.
nn_module
Callsnn_reshape() when trained.This internally callstorch::torch_reshape() with the givenshape.
Parameters
shape::integer(1)
The desired output shape. Unknown dimension (one at most) can either be specified as-1.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchReshape
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchReshape$new(id = "nn_reshape", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchReshape$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_reshape")pipeop# The available parameterspipeop$param_setRReLU Activation Function
Description
Randomized leaky ReLU.
nn_module
Callstorch::nn_rrelu() when trained.
Parameters
lower::numeric(1)
Lower bound of the uniform distribution. Default: 1/8.upper::numeric(1)
Upper bound of the uniform distribution. Default: 1/3.inplace::logical(1)
Whether to do the operation in-place. Default:FALSE.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchRReLU
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchRReLU$new(id = "nn_rrelu", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchRReLU$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_rrelu")pipeop# The available parameterspipeop$param_setSELU Activation Function
Description
Applies element-wise,
SELU(x) = scale * (max(0,x) + min(0, \alpha * (exp(x) - 1)))
,with\alpha=1.6732632423543772848170429916717 andscale=1.0507009873554804934193349852946.
nn_module
Callstorch::nn_selu() when trained.
Parameters
inplace::logical(1)
Whether to do the operation in-place. Default:FALSE.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchSELU
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchSELU$new(id = "nn_selu", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchSELU$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_selu")pipeop# The available parameterspipeop$param_setSigmoid Activation Function
Description
Applies element-wiseSigmoid(x_i) = \frac{1}{1 + exp(-x_i)}
nn_module
Callstorch::nn_sigmoid() when trained.
Parameters
No parameters.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchSigmoid
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchSigmoid$new(id = "nn_sigmoid", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchSigmoid$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_sigmoid")pipeop# The available parameterspipeop$param_setSoftmax
Description
Applies a softmax function.
nn_module
Callstorch::nn_softmax() when trained.
Parameters
dim::integer(1)
A dimension along which Softmax will be computed (so every slice along dim will sum to 1).
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchSoftmax
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchSoftmax$new(id = "nn_softmax", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchSoftmax$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_softmax")pipeop# The available parameterspipeop$param_setSoftPlus Activation Function
Description
Applies element-wise, the functionSoftplus(x) = 1/\beta * log(1 + exp(\beta * x)).
nn_module
Callstorch::nn_softplus() when trained.
Parameters
beta::numeric(1)
The beta value for the Softplus formulation. Default: 1threshold::numeric(1)
Values above this revert to a linear function. Default: 20
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchSoftPlus
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchSoftPlus$new(id = "nn_softplus", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchSoftPlus$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_softplus")pipeop# The available parameterspipeop$param_setSoft Shrink Activation Function
Description
Applies the soft shrinkage function elementwise
nn_module
Callstorch::nn_softshrink() when trained.
Parameters
lamd::numeric(1)
The lambda (must be no less than zero) value for the Softshrink formulation. Default: 0.5
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchSoftShrink
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchSoftShrink$new(id = "nn_softshrink", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchSoftShrink$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_softshrink")pipeop# The available parameterspipeop$param_setSoftSign Activation Function
Description
Applies element-wise, the functionSoftSign(x) = x/(1 + |x|
nn_module
Callstorch::nn_softsign() when trained.
Parameters
No parameters.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchSoftSign
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchSoftSign$new(id = "nn_softsign", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchSoftSign$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_softsign")pipeop# The available parameterspipeop$param_setSqueeze a Tensor
Description
Squeezes a tensor by callingtorch::torch_squeeze() with the given dimensiondim.
nn_module
Callsnn_squeeze() when trained.
Parameters
dim::integer(1)
The dimension to squeeze. IfNULL, all dimensions of size 1 will be squeezed.Negative values are interpreted downwards from the last dimension.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchSqueeze
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchSqueeze$new(id = "nn_squeeze", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchSqueeze$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_squeeze")pipeop# The available parameterspipeop$param_setTanh Activation Function
Description
Applies the element-wise function:
nn_module
Callstorch::nn_tanh() when trained.
Parameters
No parameters.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchTanh
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchTanh$new(id = "nn_tanh", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchTanh$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_tanh")pipeop# The available parameterspipeop$param_setTanh Shrink Activation Function
Description
Applies element-wise,Tanhshrink(x) = x - Tanh(x)
nn_module
Callstorch::nn_tanhshrink() when trained.
Parameters
No parameters.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchTanhShrink
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchTanhShrink$new(id = "nn_tanhshrink", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchTanhShrink$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_tanhshrink")pipeop# The available parameterspipeop$param_setTreshold Activation Function
Description
Thresholds each element of the input Tensor.
nn_module
Callstorch::nn_threshold() when trained.
Parameters
threshold::numeric(1)
The value to threshold at.value::numeric(1)
The value to replace with.inplace::logical(1)
Can optionally do the operation in-place. Default:FALSE.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchThreshold
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchThreshold$new(id = "nn_threshold", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchThreshold$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_threshold", threshold = 1, value = 2)pipeop# The available parameterspipeop$param_setCategorical Tokenizer
Description
Tokenizes categorical features into a dense embedding.For an input of shape(batch, n_features) the output shape is(batch, n_features, d_token).
nn_module
Callsnn_tokenizer_categ() when trained where the parametercardinalities is inferred.The output shape is(batch, n_features, d_token).
Parameters
d_token::integer(1)
The dimension of the embedding.bias::logical(1)
Whether to use a bias. Is initialized toTRUE.initialization::character(1)
The initialization method for the embedding weights. Possible values are"uniform"(default)and"normal".cardinalities::integer()
The number of categories for each feature.Only needs to be provided when working withlazy_tensorinputs.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchTokenizerCateg
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchTokenizerCateg$new(id = "nn_tokenizer_categ", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchTokenizerCateg$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_tokenizer_categ", d_token = 10)pipeop# The available parameterspipeop$param_setNumeric Tokenizer
Description
Tokenizes numeric features into a dense embedding.For an input of shape(batch, n_features) the output shape is(batch, n_features, d_token).
nn_module
Callsnn_tokenizer_num() when trained where the parametern_features is inferred.The output shape is(batch, n_features, d_token).
Parameters
d_token::integer(1)
The dimension of the embedding.bias::logical(1)
Whether to use a bias. Is initialized toTRUE.initialization::character(1)
The initialization method for the embedding weights. Possible values are"uniform"(default)and"normal".
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchTokenizerNum
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchTokenizerNum$new(id = "nn_tokenizer_num", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchTokenizerNum$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_tokenizer_num", d_token = 10)pipeop# The available parameterspipeop$param_setUnqueeze a Tensor
Description
Unsqueezes a tensor by callingtorch::torch_unsqueeze() with the given dimensiondim.
nn_module
Callsnn_unsqueeze() when trained.This internally callstorch::torch_unsqueeze().
Parameters
dim::integer(1)
The dimension which to unsqueeze. Negative values are interpreted downwards from the last dimension.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public method$shapes_out().
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorch ->PipeOpTorchUnsqueeze
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchUnsqueeze$new(id = "nn_unsqueeze", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchUnsqueeze$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
# Construct the PipeOppipeop = po("nn_unsqueeze")pipeop# The available parameterspipeop$param_setBase Class for Lazy Tensor Preprocessing
Description
ThisPipeOp can be used to preprocess (one or more)lazy_tensor columns contained in anmlr3::Task.The preprocessing function is specified as construction argumentfn and additional arguments to thisfunction can be defined through thePipeOp's parameter set.The preprocessing is done per column, i.e. the number of lazy tensor output columns is equalto the number of lazy tensor input columns.
To create custom preprocessingPipeOps you can usepipeop_preproc_torch.
Inheriting
In addition to specifying the construction arguments, you can overwrite the private.shapes_out() method.If you don't overwrite it, the output shapes are assumed to be unknown (NULL).
.shapes_out(shapes_in, param_vals, task)
(list(),list(), TaskorNULL) -> list()\cr This private method calculates the output shapes of the lazy tensor columns that are created from applying the preprocessing function with the provided parameter values (param_vals). The taskis very rarely needed, but if it is it should be checked that it is notNULL'.This private method only has the responsibility to calculate the output shapes for one input column, i.e. theinput
shapes_incan be assumed to have exactly one shape vector for which it must calculate the output shapesand return it as alist()of length 1.It can also be assumed that the shape is notNULL(i.e. unknown).Also, the first dimension can beNA, i.e. is unknown (as for the batch dimension).
Input and Output Channels
State
In addition to state elements fromPipeOpTaskPreprocSimple,the state also contains the$param_vals that were set during training.
Parameters
In addition to the parameters inherited fromPipeOpTaskPreproc as well as those specified during constructionas the argumentparam_set there are the following parameters:
stages::character(1)
The stages during which to apply the preprocessing.Can be one of"train","predict"or"both".The initial value of this parameter is set to"train"when thePipeOp's id starts with"augment_"andto"both"otherwise.Note that the preprocessing that is applied during$predict()uses the parameters that were set during$train()and not those that are set when performing the prediction.
Internals
During$train() /$predict(), aPipeOpModule with one input and one output channel is created.The pipeop applies the functionfn to the input tensor while additionallypassing the parameter values (minusstages andaffect_columns) tofn.The preprocessing graph of the lazy tensor columns is shallowly cloned and thePipeOpModule is added.This is done to avoid modifying user input and means that identicalPipeOpModules can be part of differentpreprocessing graphs. This is only possible, because the createdPipeOpModule is stateless.
At a later point in the graph, preprocessing graphs will be merged if possible to avoid unnecessary computation.This is best illustrated by example:One lazy tensor column's preprocessing graph isA -> B.Then, two branches are createdB -> C andB -> D, creating two preprocessing graphsA -> B -> C andA -> B -> D. When loading the data, we want to run the preprocessing only once, i.e. we don'twant to run theA -> B part twice. For this reason,task_dataset() will try to merge graphs and cacheresults from graphs. However, only graphs using the same dataset can currently be merged.
Also, the shapes created during$train() and$predict() might differ.To avoid the creation of graphs where the predict shapes are incompatible with the train shapes,the hypothetical predict shapes are already calculated during$train() (this is why the parameters that are setduring train are also used during predict) and thePipeOpTorchModel will check the train and predict shapes forcompatibility before starting the training.
Otherwise, this mechanism is very similar to theModelDescriptor construct.
Super classes
mlr3pipelines::PipeOp ->mlr3pipelines::PipeOpTaskPreproc ->PipeOpTaskPreprocTorch
Active bindings
fnThe preprocessing function.
rowwiseWhether the preprocessing is applied rowwise.
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTaskPreprocTorch$new( fn, id = "preproc_torch", param_vals = list(), param_set = ps(), packages = character(0), rowwise = FALSE, stages_init = NULL, tags = NULL)
Arguments
fn(
functionorcharacter(2))
The preprocessing function. Must not modify its input in-place.If it is acharacter(2), the first element should be the namespace and the second element the name.When the preprocessing function is applied to the tensor, the tensor will be passed by position as the first argument.If theparam_setis inferred (left asNULL) it is assumed that the first argument is thetorch_tensor.id(
character(1))
The id for of the new object.param_vals(named
list())
Parameter values to be set after construction.param_set(
ParamSet)
In case the functionfntakes additional parameter besides atorch_tensorthey can bespecfied as parameters. None of the parameters can have the"predict"tag.All tags should include"train".packages(
character())
The packages the preprocessing function depends on.rowwise(
logical(1))
Whether the preprocessing function is applied rowwise (and then concatenated by row) or directly to the wholetensor. In the first case there is no batch dimension.stages_init(
character(1))
Initial value for thestagesparameter.tags(
character())
Tags for the pipeop.
Methodshapes_out()
Calculates the output shapes that would result in applying the preprocessing to one or morelazy tensor columns with the provided shape.Names are ignored and only order matters.It uses the parameter values that are currently set.
Usage
PipeOpTaskPreprocTorch$shapes_out(shapes_in, stage = NULL, task = NULL)
Arguments
shapes_in(
list()of (integer()orNULL))
The input input shapes of the lazy tensors.NULLindicates that the shape is unknown.First dimension must beNA(if it is notNULL).stage(
character(1))
The stage: either"train"or"predict".task(
TaskorNULL)
The task, which is very rarely needed.
Returns
list() of (integer() orNULL)
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTaskPreprocTorch$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
# Creating a simple taskd = data.table( x1 = as_lazy_tensor(rnorm(10)), x2 = as_lazy_tensor(rnorm(10)), x3 = as_lazy_tensor(as.double(1:10)), y = rnorm(10))taskin = as_task_regr(d, target = "y")# Creating a simple preprocessing pipeoppo_simple = po("preproc_torch", # get rid of environment baggage fn = mlr3misc::crate(function(x, a) x + a), param_set = paradox::ps(a = paradox::p_int(tags = c("train", "required"))))po_simple$param_set$set_values( a = 100, affect_columns = selector_name(c("x1", "x2")), stages = "both" # use during train and predict)taskout_train = po_simple$train(list(taskin))[[1L]]materialize(taskout_train$data(cols = c("x1", "x2")), rbind = TRUE)taskout_predict_noaug = po_simple$predict(list(taskin))[[1L]]materialize(taskout_predict_noaug$data(cols = c("x1", "x2")), rbind = TRUE)po_simple$param_set$set_values( stages = "train")# transformation is not appliedtaskout_predict_aug = po_simple$predict(list(taskin))[[1L]]materialize(taskout_predict_aug$data(cols = c("x1", "x2")), rbind = TRUE)# Creating a more complex preprocessing PipeOpPipeOpPreprocTorchPoly = R6::R6Class("PipeOpPreprocTorchPoly", inherit = PipeOpTaskPreprocTorch, public = list( initialize = function(id = "preproc_poly", param_vals = list()) { param_set = paradox::ps( n_degree = paradox::p_int(lower = 1L, tags = c("train", "required")) ) param_set$set_values( n_degree = 1L ) fn = mlr3misc::crate(function(x, n_degree) { torch::torch_cat( lapply(seq_len(n_degree), function(d) torch::torch_pow(x, d)), dim = 2L ) }) super$initialize( fn = fn, id = id, packages = character(0), param_vals = param_vals, param_set = param_set, stages_init = "both" ) } ), private = list( .shapes_out = function(shapes_in, param_vals, task) { # shapes_in is a list of length 1 containing the shapes checkmate::assert_true(length(shapes_in[[1L]]) == 2L) if (shapes_in[[1L]][2L] != 1L) { stop("Input shape must be (NA, 1)") } list(c(NA, param_vals$n_degree)) } ))po_poly = PipeOpPreprocTorchPoly$new( param_vals = list(n_degree = 3L, affect_columns = selector_name("x3")))po_poly$shapes_out(list(c(NA, 1L)), stage = "train")taskout = po_poly$train(list(taskin))[[1L]]materialize(taskout$data(cols = "x3"), rbind = TRUE)Base Class for Torch Module Constructor Wrappers
Description
PipeOpTorch is the base class for allPipeOps that representneural network layers in aGraph.Duringtraining, it generates aPipeOpModule that wraps annn_module and attaches itto the architecture, which is also represented as aGraph consisting mostly ofPipeOpModulesanPipeOpNOPs.
While the formerGraph operates onModelDescriptors, the latter operates ontensors.
The relationship between aPipeOpTorch and aPipeOpModule is similar to therelationshop between ann_module_generator (likenn_linear) and ann_module (like the output ofnn_linear(...)).A crucial difference is that thePipeOpTorch infers auxiliary parameters (likein_features fornn_linear) automatically from the intermediate tensor shapes that are being communicated through theModelDescriptor.
Duringprediction,PipeOpTorch takes in aTask in each channel and outputs the same newTask resulting from theirfeature union in each channel.If there is only one input and output channel, the task is simply piped through.
Parameters
TheParamSet is specified by the child class inheriting fromPipeOpTorch.Usually the parameters are the arguments of the wrappednn_module minus the auxiliary parameter that canbe automatically inferred from the shapes of the input tensors.
Inheriting
When inheriting from this class, one should overload either theprivate$.shapes_out() and theprivate$.shape_dependent_params() methods, or overloadprivate$.make_module().
.make_module(shapes_in, param_vals, task)
(list(),list()) ->nn_module
This private method is called to generate thenn_modulethat is passed as argumentmoduletoPipeOpModule. It must be overwritten, when nomodule_generatoris provided.If left as is, it calls the providedmodule_generatorwith the arguments obtained bythe private method.shape_dependent_params()..shapes_out(shapes_in, param_vals, task)
(list(),list(),TaskorNULL) -> namedlist()
This private method gets a list ofintegervectors (shapes_in), the parameter values (param_vals),as well as an (optional)Task.Theshapes_incan be assumed to be in the same order as the input names of thePipeOp.The output shapes must be in the same order as the output names of thePipeOp.In case the output shapes depends on the task (as is the case forPipeOpTorchHead), the function should returnvalid output shapes (possibly containingNAs) if thetaskargument is provided or not.It is important to properly handle the presence ofNAs in the input shapes.By default (if construction argumentonly_batch_unknownisTRUE), only the batch dimension can beNA.If you set this toFALSE, you need to take other unknown dimensions into account.The method can also throw an error if the input shapes violate some assumptions..shape_dependent_params(shapes_in, param_vals, task)
(list(),list()) -> namedlist()
This private method has the same inputs as.shapes_out.If.make_module()is not overwritten, it constructs the arguments passed tomodule_generator.Usually this means that it must infer the auxiliary parameters that can be inferred from the input shapesand add it to the user-supplied parameter values (param_vals).
Input and Output Channels
Duringtraining, all inputs and outputs are of classModelDescriptor.Duringprediction, all input and output channels are of classTask.
State
The state is the value calculated by the public methodshapes_out().
Internals
During training, thePipeOpTorch creates aPipeOpModule for the given parameter specification and theinput shapes from the incomingModelDescriptors using the private method.make_module().The input shapes are provided by the slotpointer_shape of the incomingModelDescriptors.The channel names of thisPipeOpModule are identical to the channel names of the generatingPipeOpTorch.
Amodel descriptor union of all incomingModelDescriptors is then created.Note that this modifies thegraph of the firstModelDescriptorin place for efficiency.ThePipeOpModule is added to thegraph slot of this union and the the edges that connect thesendingPipeOpModules to the input channel of thisPipeOpModule are addeded to the graph.This is possible because every incomingModelDescriptor contains the information about theid and thechannel name of the sendingPipeOp in the slotpointer.
The new graph in themodel_descriptor_union represents the current state of the neural networkarchitecture. It is structurally similar to the subgraph that consists of all pipeops of classPipeOpTorch andPipeOpTorchIngress that are ancestors of thisPipeOpTorch.
For the output, a shallow copy of theModelDescriptor is created and thepointer andpointer_shape are updated accordingly. The shallow copy means that allModelDescriptors point to the sameGraph which allows the graph to be modified by-reference in different parts of the code.
Super class
mlr3pipelines::PipeOp ->PipeOpTorch
Public fields
module_generator(
nn_module_generatororNULL)
The module generator wrapped by thisPipeOpTorch. IfNULL, the private methodprivate$.make_module(shapes_in, param_vals)must be overwritte, see section 'Inheriting'.Do not change this after construction.
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorch$new( id, module_generator, param_set = ps(), param_vals = list(), inname = "input", outname = "output", packages = "torch", tags = NULL, only_batch_unknown = TRUE)
Arguments
id(
character(1))
Identifier of the resulting object.module_generator(
nn_module_generator)
The torch module generator.param_set(
ParamSet)
The parameter set.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.inname(
character())
The names of thePipeOp's input channels. These will be the input channels of the generatedPipeOpModule.Unless the wrappedmodule_generator's forward method (if present) has the argument...,innamemust beidentical to those argument names in order to avoid any ambiguity.
If the forward method has the argument..., the order of the input channels determines how the tensorswill be passed to the wrappednn_module.
If left asNULL(default), the argumentmodule_generatormust be given and the argument names of themodue_generator's forward function are set asinname.outname(
character())
The names of the output channels channels. These will be the ouput channels of the generatedPipeOpModuleand therefore also the names of the list returned by its$train().In case there is more than one output channel, thenn_modulethat is constructed by thisPipeOpduring training must return a namedlist(), where the names of the list are thenames out the output channels. The default is"output".packages(
character())
The R packages this object depends on.tags(
character())
The tags of thePipeOp. The tags"torch"is always added.only_batch_unknown(
logical(1))
Whether only the batch dimension can be missing in the input shapes or whether otherdimensions can also be unknown.Default isTRUE.
Methodshapes_out()
Calculates the output shapes for the given input shapes, parameters and task.
Usage
PipeOpTorch$shapes_out(shapes_in, task = NULL)
Arguments
shapes_in(
list()ofinteger())
The input input shapes, which must be in the same order as the input channel names of thePipeOp.task(
TaskorNULL)
The task, which is very rarely used (default isNULL). An exception isPipeOpTorchHead.
Returns
A namedlist() containing the output shapes. The names are the names of the output channels ofthePipeOp.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorch$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Graph Network:ModelDescriptor(),TorchIngressToken(),mlr_learners_torch_model,mlr_pipeops_module,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,model_descriptor_to_learner(),model_descriptor_to_module(),model_descriptor_union(),nn_graph()
Examples
## Creating a neural network# In torchtask = tsk("iris")network_generator = torch::nn_module( initialize = function(task, d_hidden) { d_in = length(task$feature_names) self$linear = torch::nn_linear(d_in, d_hidden) self$output = if (task$task_type == "regr") { torch::nn_linear(d_hidden, 1) } else if (task$task_type == "classif") { torch::nn_linear(d_hidden, output_dim_for(task)) } }, forward = function(x) { x = self$linear(x) x = torch::nnf_relu(x) self$output(x) })network = network_generator(task, d_hidden = 50)x = torch::torch_tensor(as.matrix(task$data(1, task$feature_names)))y = torch::with_no_grad(network(x))# In mlr3torchnetwork_generator = po("torch_ingress_num") %>>% po("nn_linear", out_features = 50) %>>% po("nn_head")md = network_generator$train(task)[[1L]]network = model_descriptor_to_module(md)y = torch::with_no_grad(network(torch_ingress_num.input = x))## Implementing a custom PipeOpTorch# defining a custom modulenn_custom = nn_module("nn_custom", initialize = function(d_in1, d_in2, d_out1, d_out2, bias = TRUE) { self$linear1 = nn_linear(d_in1, d_out1, bias) self$linear2 = nn_linear(d_in2, d_out2, bias) }, forward = function(input1, input2) { output1 = self$linear1(input1) output2 = self$linear1(input2) list(output1 = output1, output2 = output2) })# wrapping the module into a custom PipeOpTorchlibrary(paradox)PipeOpTorchCustom = R6::R6Class("PipeOpTorchCustom", inherit = PipeOpTorch, public = list( initialize = function(id = "nn_custom", param_vals = list()) { param_set = ps( d_out1 = p_int(lower = 1, tags = c("required", "train")), d_out2 = p_int(lower = 1, tags = c("required", "train")), bias = p_lgl(default = TRUE, tags = "train") ) super$initialize( id = id, param_vals = param_vals, param_set = param_set, inname = c("input1", "input2"), outname = c("output1", "output2"), module_generator = nn_custom ) } ), private = list( .shape_dependent_params = function(shapes_in, param_vals, task) { c(param_vals, list(d_in1 = tail(shapes_in[["input1"]], 1)), d_in2 = tail(shapes_in[["input2"]], 1) ) }, .shapes_out = function(shapes_in, param_vals, task) { list( input1 = c(head(shapes_in[["input1"]], -1), param_vals$d_out1), input2 = c(head(shapes_in[["input2"]], -1), param_vals$d_out2) ) } ))## Training# generate inputtask = tsk("iris")task1 = task$clone()$select(paste0("Sepal.", c("Length", "Width")))task2 = task$clone()$select(paste0("Petal.", c("Length", "Width")))graph = gunion(list(po("torch_ingress_num_1"), po("torch_ingress_num_2")))mds_in = graph$train(list(task1, task2), single_input = FALSE)mds_in[[1L]][c("graph", "task", "ingress", "pointer", "pointer_shape")]mds_in[[2L]][c("graph", "task", "ingress", "pointer", "pointer_shape")]# creating the PipeOpTorch and training itpo_torch = PipeOpTorchCustom$new()po_torch$param_set$values = list(d_out1 = 10, d_out2 = 20)train_input = list(input1 = mds_in[[1L]], input2 = mds_in[[2L]])mds_out = do.call(po_torch$train, args = list(input = train_input))po_torch$state# the new model descriptors# the resulting graphs are identicalidentical(mds_out[[1L]]$graph, mds_out[[2L]]$graph)# note that as a side-effect, also one of the input graphs is modified in-place for efficiencymds_in[[1L]]$graph$edges# The new task has both Sepal and Petal featuresidentical(mds_out[[1L]]$task, mds_out[[2L]]$task)mds_out[[2L]]$task# The new ingress slot contains all ingressorsidentical(mds_out[[1L]]$ingress, mds_out[[2L]]$ingress)mds_out[[1L]]$ingress# The pointer and pointer_shape slots are differentmds_out[[1L]]$pointermds_out[[2L]]$pointermds_out[[1L]]$pointer_shapemds_out[[2L]]$pointer_shape## Predictionpredict_input = list(input1 = task1, input2 = task2)tasks_out = do.call(po_torch$predict, args = list(input = predict_input))identical(tasks_out[[1L]], tasks_out[[2L]])Callback Configuration
Description
Configures the callbacks of a deep learning model.
Parameters
The parameters are defined dynamically from the callbacks, where the id of the respective callbacks is therespective set id.
Input and Output Channels
There is one input channel"input" and one output channel"output".Duringtraining, the channels are of classModelDescriptor.Duringprediction, the channels are of classTask.
State
The state is the value calculated by the public methodshapes_out().
Internals
During training the callbacks are cloned and added to theModelDescriptor.
Super class
mlr3pipelines::PipeOp ->PipeOpTorchCallbacks
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchCallbacks$new( callbacks = list(), id = "torch_callbacks", param_vals = list())
Arguments
callbacks(
listofTorchCallbacks)
The callbacks (or something convertible viaas_torch_callbacks()).Must have unique ids.All callbacks are cloned during construction.id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchCallbacks$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Model Configuration:ModelDescriptor(),mlr_pipeops_torch_loss,mlr_pipeops_torch_optimizer,model_descriptor_union()
Other PipeOp:mlr_pipeops_module,mlr_pipeops_torch_optimizer
Examples
po_cb = po("torch_callbacks", "checkpoint")po_cb$param_setmdin = po("torch_ingress_num")$train(list(tsk("iris")))mdin[[1L]]$callbacksmdout = po_cb$train(mdin)[[1L]]mdout$callbacks# Can be called againpo_cb1 = po("torch_callbacks", t_clbk("progress"))mdout1 = po_cb1$train(list(mdout))[[1L]]mdout1$callbacksEntrypoint to Torch Network
Description
Use this as entry-point to mlr3torch-networks.Unless you are an advanced user, you should not need to use this directly butPipeOpTorchIngressNumeric,PipeOpTorchIngressCategorical orPipeOpTorchIngressLazyTensor.
Parameters
Defined by the construction argumentparam_set.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is set to the input shape.
Internals
Creates an object of classTorchIngressToken for the given task.The purpuse of this is to store the information on how to construct the torch dataloader from the task for thisentry point of the network.
Super class
mlr3pipelines::PipeOp ->PipeOpTorchIngress
Active bindings
feature_types(
character(1))
The features types that can be consumed by thisPipeOpTorchIngress.
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchIngress$new( id, param_set = ps(), param_vals = list(), packages = character(0), feature_types)
Arguments
id(
character(1))
Identifier of the resulting object.param_set(
ParamSet)
The parameter set.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.packages(
character())
The R packages this object depends on.feature_types(
character())
The feature types.Seemlr_reflections$task_feature_typesfor available values,Additionally,"lazy_tensor"is supported.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchIngress$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Other Graph Network:ModelDescriptor(),TorchIngressToken(),mlr_learners_torch_model,mlr_pipeops_module,mlr_pipeops_torch,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,model_descriptor_to_learner(),model_descriptor_to_module(),model_descriptor_union(),nn_graph()
Torch Entry Point for Categorical Features
Description
Ingress PipeOp that represents a categorical (factor(),ordered() andlogical()) entry point to a torch network.
Parameters
select::logical(1)
WhetherPipeOpshould selected the supported feature types. Otherwise it will err on receiving taskswith unsupported feature types.
Internals
Usesbatchgetter_categ().
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is set to the input shape.
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorchIngress ->PipeOpTorchIngressCategorical
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchIngressCategorical$new( id = "torch_ingress_categ", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchIngressCategorical$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Other Graph Network:ModelDescriptor(),TorchIngressToken(),mlr_learners_torch_model,mlr_pipeops_module,mlr_pipeops_torch,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,model_descriptor_to_learner(),model_descriptor_to_module(),model_descriptor_union(),nn_graph()
Examples
graph = po("select", selector = selector_type("factor")) %>>% po("torch_ingress_categ")task = tsk("german_credit")# The output is a model descriptormd = graph$train(task)[[1L]]ingress = md$ingress[[1L]]ingress$batchgetter(task$data(1, ingress$features(task)), "cpu")Ingress for Lazy Tensor
Description
Ingress for a singlelazy_tensor column.
Parameters
shape::integer()|NULL|"infer"
The shape of the tensor, where the first dimension (batch) must beNA.When it is not specified, the lazy tensor input column needs to have a known shape.When it is set to"infer", the shape is inferred from an example batch.
Internals
The returned batchgetter materializes the lazy tensor column to a tensor.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is set to the input shape.
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorchIngress ->PipeOpTorchIngressLazyTensor
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchIngressLazyTensor$new( id = "torch_ingress_ltnsr", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchIngressLazyTensor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Other Graph Network:ModelDescriptor(),TorchIngressToken(),mlr_learners_torch_model,mlr_pipeops_module,mlr_pipeops_torch,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_num,model_descriptor_to_learner(),model_descriptor_to_module(),model_descriptor_union(),nn_graph()
Examples
po_ingress = po("torch_ingress_ltnsr")task = tsk("lazy_iris")md = po_ingress$train(list(task))[[1L]]ingress = md$ingressx_batch = ingress[[1L]]$batchgetter(data = task$data(1, "x"), cache = NULL)x_batch# Now we try a lazy tensor with unknown shape, i.e. the shapes between the rows can differds = dataset( initialize = function() self$x = list(torch_randn(3, 10, 10), torch_randn(3, 8, 8)), .getitem = function(i) list(x = self$x[[i]]), .length = function() 2)()task_unknown = as_task_regr(data.table( x = as_lazy_tensor(ds, dataset_shapes = list(x = NULL)), y = rnorm(2)), target = "y", id = "example2")# this task (as it is) can NOT be processed by PipeOpTorchIngressLazyTensor# It therefore needs to be preprocessedpo_resize = po("trafo_resize", size = c(6, 6))task_unknown_resize = po_resize$train(list(task_unknown))[[1L]]# printing the transformed column still shows unknown shapes,# because the preprocessing pipeop cannot infer them,# however we know that the shape is now (3, 10, 10) for all rowstask_unknown_resize$data(1:2, "x")po_ingress$param_set$set_values(shape = c(NA, 3, 6, 6))md2 = po_ingress$train(list(task_unknown_resize))[[1L]]ingress2 = md2$ingressx_batch2 = ingress2[[1L]]$batchgetter( data = task_unknown_resize$data(1:2, "x"), cache = NULL)x_batch2Torch Entry Point for Numeric Features
Description
Ingress PipeOp that represents a numeric (integer() andnumeric()) entry point to a torch network.
Internals
Usesbatchgetter_num().
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is set to the input shape.
Super classes
mlr3pipelines::PipeOp ->mlr3torch::PipeOpTorchIngress ->PipeOpTorchIngressNumeric
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchIngressNumeric$new(id = "torch_ingress_num", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchIngressNumeric$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Graph Network:ModelDescriptor(),TorchIngressToken(),mlr_learners_torch_model,mlr_pipeops_module,mlr_pipeops_torch,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,model_descriptor_to_learner(),model_descriptor_to_module(),model_descriptor_union(),nn_graph()
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Examples
graph = po("select", selector = selector_type(c("numeric", "integer"))) %>>% po("torch_ingress_num")task = tsk("german_credit")# The output is a model descriptormd = graph$train(task)[[1L]]ingress = md$ingress[[1L]]ingress$batchgetter(task$data(1:5, ingress$features(task)), "cpu")Loss Configuration
Description
Configures the loss of a deep learning model.
Input and Output Channels
One input channel called"input" and one output channel called"output".For an explanation seePipeOpTorch.
State
The state is the value calculated by the public methodshapes_out().
Parameters
The parameters are defined dynamically from the loss set during construction.
Internals
During training the loss is cloned and added to theModelDescriptor.
Super class
mlr3pipelines::PipeOp ->PipeOpTorchLoss
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchLoss$new(loss, id = "torch_loss", param_vals = list())
Arguments
loss(
TorchLossorcharacter(1)ornn_loss)
The loss (or something convertible viaas_torch_loss()).id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchLoss$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
Other Model Configuration:ModelDescriptor(),mlr_pipeops_torch_callbacks,mlr_pipeops_torch_optimizer,model_descriptor_union()
Examples
po_loss = po("torch_loss", loss = t_loss("cross_entropy"))po_loss$param_setmdin = po("torch_ingress_num")$train(list(tsk("iris")))mdin[[1L]]$lossmdout = po_loss$train(mdin)[[1L]]mdout$lossPipeOp Torch Model
Description
Builds a Torch Learner from aModelDescriptor and trains it with the given parameter specification.The task type must be specified during construction.
Parameters
General:
The parameters of the optimizer, loss and callbacks,prefixed with"opt.","loss." and"cb.<callback id>." respectively, as well as:
epochs::integer(1)
The number of epochs.device::character(1)
The device. One of"auto","cpu", or"cuda"or other values defined inmlr_reflections$torch$devices.The value is initialized to"auto", which will select"cuda"if possible, then try"mps"and otherwisefall back to"cpu".num_threads::integer(1)
The number of threads for intraop pararallelization (ifdeviceis"cpu").This value is initialized to 1.num_interop_threads::integer(1)
The number of threads for intraop and interop pararallelization (ifdeviceis"cpu").This value is initialized to 1.Note that this can only be set once during a session and changing the value within an R session will raise a warning.seed::integer(1)or"random"orNULL
The torch seed that is used during training and prediction.This value is initialized to"random", which means that a random seed will be sampled at the beginning of thetraining phase. This seed (either set or randomly sampled) is available via$model$seedafter trainingand used during prediction.Note that by setting the seed during the training phase this will mean that by default (i.e. whenseedis"random"), clones of the learner will use a different seed.If set toNULL, no seeding will be done.tensor_dataset::logical(1)|"device"
Whether to load all batches at once at the beginning of training and stack them.This is initialized toFALSE.If set to"device", the device of the tensors will be set to the value ofdevice, whichcan avoid unnecessary moving of tensors between devices.When your dataset fits into memory this will make the loading of batches faster.Note that this should not be set for datasets that containlazy_tensors with random data augmentation,as this augmentation will only be applied once at the beginning of training.
Evaluation:
measures_train::Measureorlist()ofMeasures
Measures to be evaluated during training.measures_valid::Measureorlist()ofMeasures
Measures to be evaluated during validation.eval_freq::integer(1)
How often the train / validation predictions are evaluated usingmeasures_train/measures_valid.This is initialized to1.Note that the final model is always evaluated.
Early Stopping:
patience::integer(1)
This activates early stopping using the validation scores.If the performance of a model does not improve forpatienceevaluation steps, training is ended.Note that the final model is stored in the learner, not the best model.This is initialized to0, which means no early stopping.The first entry frommeasures_validis used as the metric.This also requires to specify the$validatefield of the Learner, as well asmeasures_valid.If this is set, the epoch after which no improvement was observed, can be accessed via the$internal_tuned_valuesfield of the learner.min_delta::double(1)
The minimum improvement threshold for early stopping.Is initialized to 0.
Dataloader:
batch_size::integer(1)
The batch size (required).shuffle::logical(1)
Whether to shuffle the instances in the dataset. This is initialized toTRUE,which differs from the default (FALSE).sampler::torch::sampler
Object that defines how the dataloader draw samples.batch_sampler::torch::sampler
Object that defines how the dataloader draws batches.num_workers::integer(1)
The number of workers for data loading (batches are loaded in parallel).The default is0, which means that data will be loaded in the main process.collate_fn::function
How to merge a list of samples to form a batch.pin_memory::logical(1)
Whether the dataloader copies tensors into CUDA pinned memory before returning them.drop_last::logical(1)
Whether to drop the last training batch in each epoch during training. Default isFALSE.timeout::numeric(1)
The timeout value for collecting a batch from workers.Negative values mean no timeout and the default is-1.worker_init_fn::function(id)
A function that receives the worker id (in[1, num_workers]) and is exectued after seedingon the worker but before data loading.worker_globals::list()|character()
When loading data in parallel, this allows to export globals to the workers.If this is a character vector, the objects in the global environment with those namesare copied to the workers.worker_packages::character()
Which packages to load on the workers.
Also seetorch::dataloder for more information.
Input and Output Channels
There is one input channel"input" that takes inModelDescriptor during traing and aTask of the specifiedtask_type during prediction.The output isNULL during training and aPrediction of giventask_type during prediction.
State
A trainedLearnerTorchModel.
Internals
ALearnerTorchModel is created by callingmodel_descriptor_to_learner() on theprovidedModelDescriptor that is received through the input channel.Then the parameters are set according to the parameters specified inPipeOpTorchModel andits '$train() method is called on the [Task][mlr3::Task] stored in the [ModelDescriptor'].
Super classes
mlr3pipelines::PipeOp ->mlr3pipelines::PipeOpLearner ->PipeOpTorchModel
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchModel$new(task_type, id = "torch_model", param_vals = list())
Arguments
task_type(
character(1))
The task type of the model.id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchModel$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model_classif,mlr_pipeops_torch_model_regr
PipeOp Torch Classifier
Description
Builds a torch classifier and trains it.
Parameters
SeeLearnerTorch
Input and Output Channels
There is one input channel"input" that takes inModelDescriptor during traing and aTask of the specifiedtask_type during prediction.The output isNULL during training and aPrediction of giventask_type during prediction.
State
A trainedLearnerTorchModel.
Internals
ALearnerTorchModel is created by callingmodel_descriptor_to_learner() on theprovidedModelDescriptor that is received through the input channel.Then the parameters are set according to the parameters specified inPipeOpTorchModel andits '$train() method is called on the [Task][mlr3::Task] stored in the [ModelDescriptor'].
Super classes
mlr3pipelines::PipeOp ->mlr3pipelines::PipeOpLearner ->mlr3torch::PipeOpTorchModel ->PipeOpTorchModelClassif
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchModelClassif$new(id = "torch_model_classif", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchModelClassif$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_regr
Examples
# simple logistic regression# configure the model descriptormd = as_graph(po("torch_ingress_num") %>>% po("nn_head") %>>% po("torch_loss", "cross_entropy") %>>% po("torch_optimizer", "adam"))$train(tsk("iris"))[[1L]]print(md)# build the learner from the model descriptor and train itpo_model = po("torch_model_classif", batch_size = 50, epochs = 1)po_model$train(list(md))po_model$stateTorch Regression Model
Description
Builds a torch regression model and trains it.
Parameters
SeeLearnerTorch
Input and Output Channels
There is one input channel"input" that takes inModelDescriptor during traing and aTask of the specifiedtask_type during prediction.The output isNULL during training and aPrediction of giventask_type during prediction.
State
A trainedLearnerTorchModel.
Internals
ALearnerTorchModel is created by callingmodel_descriptor_to_learner() on theprovidedModelDescriptor that is received through the input channel.Then the parameters are set according to the parameters specified inPipeOpTorchModel andits '$train() method is called on the [Task][mlr3::Task] stored in the [ModelDescriptor'].
Super classes
mlr3pipelines::PipeOp ->mlr3pipelines::PipeOpLearner ->mlr3torch::PipeOpTorchModel ->PipeOpTorchModelRegr
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchModelRegr$new(id = "torch_model_regr", param_vals = list())
Arguments
id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchModelRegr$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOps:mlr_pipeops_nn_adaptive_avg_pool1d,mlr_pipeops_nn_adaptive_avg_pool2d,mlr_pipeops_nn_adaptive_avg_pool3d,mlr_pipeops_nn_avg_pool1d,mlr_pipeops_nn_avg_pool2d,mlr_pipeops_nn_avg_pool3d,mlr_pipeops_nn_batch_norm1d,mlr_pipeops_nn_batch_norm2d,mlr_pipeops_nn_batch_norm3d,mlr_pipeops_nn_block,mlr_pipeops_nn_celu,mlr_pipeops_nn_conv1d,mlr_pipeops_nn_conv2d,mlr_pipeops_nn_conv3d,mlr_pipeops_nn_conv_transpose1d,mlr_pipeops_nn_conv_transpose2d,mlr_pipeops_nn_conv_transpose3d,mlr_pipeops_nn_dropout,mlr_pipeops_nn_elu,mlr_pipeops_nn_flatten,mlr_pipeops_nn_ft_cls,mlr_pipeops_nn_ft_transformer_block,mlr_pipeops_nn_geglu,mlr_pipeops_nn_gelu,mlr_pipeops_nn_glu,mlr_pipeops_nn_hardshrink,mlr_pipeops_nn_hardsigmoid,mlr_pipeops_nn_hardtanh,mlr_pipeops_nn_head,mlr_pipeops_nn_identity,mlr_pipeops_nn_layer_norm,mlr_pipeops_nn_leaky_relu,mlr_pipeops_nn_linear,mlr_pipeops_nn_log_sigmoid,mlr_pipeops_nn_max_pool1d,mlr_pipeops_nn_max_pool2d,mlr_pipeops_nn_max_pool3d,mlr_pipeops_nn_merge,mlr_pipeops_nn_merge_cat,mlr_pipeops_nn_merge_prod,mlr_pipeops_nn_merge_sum,mlr_pipeops_nn_prelu,mlr_pipeops_nn_reglu,mlr_pipeops_nn_relu,mlr_pipeops_nn_relu6,mlr_pipeops_nn_reshape,mlr_pipeops_nn_rrelu,mlr_pipeops_nn_selu,mlr_pipeops_nn_sigmoid,mlr_pipeops_nn_softmax,mlr_pipeops_nn_softplus,mlr_pipeops_nn_softshrink,mlr_pipeops_nn_softsign,mlr_pipeops_nn_squeeze,mlr_pipeops_nn_tanh,mlr_pipeops_nn_tanhshrink,mlr_pipeops_nn_threshold,mlr_pipeops_nn_tokenizer_categ,mlr_pipeops_nn_tokenizer_num,mlr_pipeops_nn_unsqueeze,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,mlr_pipeops_torch_loss,mlr_pipeops_torch_model,mlr_pipeops_torch_model_classif
Examples
# simple linear regression# build the model descriptormd = as_graph(po("torch_ingress_num") %>>% po("nn_head") %>>% po("torch_loss", "mse") %>>% po("torch_optimizer", "adam"))$train(tsk("mtcars"))[[1L]]print(md)# build the learner from the model descriptor and train itpo_model = po("torch_model_regr", batch_size = 20, epochs = 1)po_model$train(list(md))po_model$stateOptimizer Configuration
Description
Configures the optimizer of a deep learning model.
Parameters
The parameters are defined dynamically from the optimizer that is set during construction.
Input and Output Channels
There is one input channel"input" and one output channel"output".Duringtraining, the channels are of classModelDescriptor.Duringprediction, the channels are of classTask.
State
The state is the value calculated by the public methodshapes_out().
Internals
During training, the optimizer is cloned and added to theModelDescriptor.Note that the parameter set of the storedTorchOptimizer is reference-identical to the parameter set of thepipeop itself.
Super class
mlr3pipelines::PipeOp ->PipeOpTorchOptimizer
Methods
Public methods
Inherited methods
Methodnew()
Creates a new instance of thisR6 class.
Usage
PipeOpTorchOptimizer$new( optimizer = t_opt("adam"), id = "torch_optimizer", param_vals = list())Arguments
optimizer(
TorchOptimizerorcharacter(1)ortorch_optimizer_generator)
The optimizer (or something convertible viaas_torch_optimizer()).id(
character(1))
Identifier of the resulting object.param_vals(
list())
List of hyperparameter settings, overwriting the hyperparameter settings that wouldotherwise be set during construction.
Methodclone()
The objects of this class are cloneable with this method.
Usage
PipeOpTorchOptimizer$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other PipeOp:mlr_pipeops_module,mlr_pipeops_torch_callbacks
Other Model Configuration:ModelDescriptor(),mlr_pipeops_torch_callbacks,mlr_pipeops_torch_loss,model_descriptor_union()
Examples
po_opt = po("torch_optimizer", "sgd", lr = 0.01)po_opt$param_setmdin = po("torch_ingress_num")$train(list(tsk("iris")))mdin[[1L]]$optimizermdout = po_opt$train(mdin)mdout[[1L]]$optimizerAdjust Brightness Transformation
Description
Callstorchvision::transform_adjust_brightness,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("trafo_adjust_brightness"")Parameters
| Id | Type | Default | Levels | Range |
| brightness_factor | numeric | - | [0, \infty) | |
| stages | character | - | train, predict, both | - |
| affect_columns | untyped | selector_all() | - | |
Adjust Gamma Transformation
Description
Callstorchvision::transform_adjust_gamma,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("trafo_adjust_gamma"")Parameters
| Id | Type | Default | Levels | Range |
| gamma | numeric | - | [0, \infty) | |
| gain | numeric | 1 | (-\infty, \infty) | |
| stages | character | - | train, predict, both | - |
| affect_columns | untyped | selector_all() | - | |
Adjust Hue Transformation
Description
Callstorchvision::transform_adjust_hue,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("trafo_adjust_hue"")Parameters
| Id | Type | Default | Levels | Range |
| hue_factor | numeric | - | [-0.5, 0.5] | |
| stages | character | - | train, predict, both | - |
| affect_columns | untyped | selector_all() | - | |
Adjust Saturation Transformation
Description
Callstorchvision::transform_adjust_saturation,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("trafo_adjust_saturation"")Parameters
| Id | Type | Default | Levels | Range |
| saturation_factor | numeric | - | (-\infty, \infty) | |
| stages | character | - | train, predict, both | - |
| affect_columns | untyped | selector_all() | - | |
Grayscale Transformation
Description
Callstorchvision::transform_grayscale,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("trafo_grayscale"")Parameters
| Id | Type | Default | Levels | Range |
| num_output_channels | integer | - | [1, 3] | |
| stages | character | - | train, predict, both | - |
| affect_columns | untyped | selector_all() | - | |
No Transformation
Description
Does nothing.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Normalization Transformation
Description
Callstorchvision::transform_normalize,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("trafo_normalize"")Parameters
| Id | Type | Default | Levels |
| mean | untyped | - | |
| std | untyped | - | |
| stages | character | - | train, predict, both |
| affect_columns | untyped | selector_all() | |
Padding Transformation
Description
Callstorchvision::transform_pad,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("trafo_pad"")Parameters
| Id | Type | Default | Levels |
| padding | untyped | - | |
| fill | untyped | 0 | |
| padding_mode | character | constant | constant, edge, reflect, symmetric |
| stages | character | - | train, predict, both |
| affect_columns | untyped | selector_all() | |
Reshaping Transformation
Description
Reshapes the tensor according to the parametershape, by callingtorch_reshape().This preprocessing function is applied batch-wise.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Parameters
shape::integer()
The desired output shape. The first dimension is the batch dimension and should usually be-1.
Resizing Transformation
Description
Callstorchvision::transform_resize,see there for more information on the parameters.The preprocessing is applied to the whole batch.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("trafo_resize"")Parameters
| Id | Type | Default | Levels |
| size | untyped | - | |
| interpolation | character | 2 | Undefined, Bartlett, Blackman, Bohman, Box, Catrom, Cosine, Cubic, Gaussian, Hamming,... |
| stages | character | - | train, predict, both |
| affect_columns | untyped | selector_all() | |
RGB to Grayscale Transformation
Description
Callstorchvision::transform_rgb_to_grayscale,see there for more information on the parameters.The preprocessing is applied to each element of a batch individually.
Format
R6Class inheriting fromPipeOpTaskPreprocTorch.
Construction
po("trafo_rgb_to_grayscale"")Parameters
| Id | Type | Default | Levels |
| stages | character | - | train, predict, both |
| affect_columns | untyped | selector_all() | |
CIFAR Classification Tasks
Description
The CIFAR-10 and CIFAR-100 datasets. A subset of the 80 million tiny images datasetwith noisy labels was supplied to student labelers, who were asked to filter outincorrectly labeled images.The images are have datatypetorch_long().
CIFAR-10 contains 10 classes. CIFAR-100 contains 100 classes, which may be partitioned into 20 superclasses of 5 classes each.The CIFAR-10 and CIFAR-100 classes are mutually exclusive.See Chapter 3.1 ofthe technical report for more details.
The data is obtained fromtorchvision::cifar10_dataset() (ortorchvision::cifar100_dataset()).
Format
R6::R6Class inheriting frommlr3::TaskClassif.
Construction
tsk("cifar10")tsk("cifar100")Download
Thetask's backend is aDataBackendLazy which will download the data once it is requested.Other meta-data is already available before that.You can cache these datasets by setting themlr3torch.cache option toTRUE or to a specific path to be usedas the cache directory.
Properties
Task type: “classif”
Properties: “multiclass”
Has Missings: no
Target: “class”
Features: “image”
Data Dimension: 60000x4
References
Krizhevsky, Alex (2009).“Learning Multiple Layers of Features from Tiny Images.”Master's thesis, Department of Computer Science, University of Toronto.
Examples
task_cifar10 = tsk("cifar10")task_cifar100 = tsk("cifar100")Iris Classification Task
Description
A classification task for the populardatasets::iris data set.Just like the iris task, but the features are represented as one lazy tensor column.
Format
R6::R6Class inheriting frommlr3::TaskClassif.
Construction
tsk("lazy_iris")Properties
Task type: “classif”
Properties: “multiclass”
Has Missings: no
Target: “Species”
Features: “x”
Data Dimension: 150x3
Source
https://en.wikipedia.org/wiki/Iris_flower_data_set
References
Anderson E (1936).“The Species Problem in Iris.”Annals of the Missouri Botanical Garden,23(3), 457.doi:10.2307/2394164.
Examples
task = tsk("lazy_iris")taskdf = task$data()materialize(df$x[1:6], rbind = TRUE)Melanoma Image classification
Description
Classification of melanoma tumor images.The data is a preprocessed version of the 2020 SIIM-ISIC challenge wherethe images have been reshaped to size $(3, 128, 128)$.
By default only the training rows are active in the task,but the test data (that has no targets) is also included.Whether an observation is part of the train or test set is indicated by the column"test".
There are no labels for the test rows, so by default, these observations are inactive,which means that the task uses only 32701 of the 43683 observations that are defined in the underlying data backend.
The data backend also contains a more detaileddiagnosis of the specific type of tumor.
Columns:
outcome(factor): the target variable. Whether the tumor is benign or malignant (the positive class)anatom_site_general_challenge(factor): the location of the tumor on the patient's bodysex(factor): the sex of the patientage_approx(int): approximate age of the patient at the time of imagingimage(lazy_tensor): The image (shape $(3, 128, 128)$) of the tumor.eesplit(character): Whether the observation os part of the train or test set.
Construction
tsk("melanoma")Download
Thetask's backend is aDataBackendLazy which will download the data once it is requested.Other meta-data is already available before that.You can cache these datasets by setting themlr3torch.cache option toTRUE or to a specific path to be usedas the cache directory.
Properties
Task type: “classif”
Properties: “twoclass”, “groups”
Has Missings: no
Target: “outcome”
Features: “sex”, “anatom_site_general_challenge”, “age_approx”, “image”
Data Dimension: 43683x11
Source
https://huggingface.co/datasets/carsonzhang/ISIC_2020_small
References
Rotemberg, V., Kurtansky, N., Betz-Stablein, B., Caffery, L., Chousakos, E., Codella, N., Combalia, M., Dusza, S., Guitera, P., Gutman, D., Halpern, A., Helba, B., Kittler, H., Kose, K., Langer, S., Lioprys, K., Malvehy, J., Musthaq, S., Nanda, J., Reiter, O., Shih, G., Stratigos, A., Tschandl, P., Weber, J., Soyer, P. (2021).“A patient-centric dataset of images and metadata for identifying melanomas using clinical context.”Scientific Data,8, 34.doi:10.1038/s41597-021-00815-z.
Examples
task = tsk("melanoma")MNIST Image classification
Description
Classic MNIST image classification.
The underlyingDataBackend contains columns"label","image","row_id","split", where the last columnindicates whether the row belongs to the train or test set.
The first 60000 rows belong to the training set, the last 10000 rows to the test set.
Construction
tsk("mnist")Download
Thetask's backend is aDataBackendLazy which will download the data once it is requested.Other meta-data is already available before that.You can cache these datasets by setting themlr3torch.cache option toTRUE or to a specific path to be usedas the cache directory.
Properties
Task type: “classif”
Properties: “multiclass”
Has Missings: no
Target: “label”
Features: “image”
Data Dimension: 70000x4
Source
https://torchvision.mlverse.org/reference/mnist_dataset.html
References
Lecun, Y., Bottou, L., Bengio, Y., Haffner, P. (1998).“Gradient-based learning applied to document recognition.”Proceedings of the IEEE,86(11), 2278-2324.doi:10.1109/5.726791.
Examples
task = tsk("mnist")Tiny ImageNet Classification Task
Description
Subset of the famous ImageNet dataset.The data is obtained fromtorchvision::tiny_imagenet_dataset().
The underlyingDataBackend contains columns"class","image","..row_id","split", where the last columnindicates whether the row belongs to the train, validation or test set that are provided in torchvision.
There are no labels for the test rows, so by default, these observations are inactive, which means that the taskuses only 110000 of the 120000 observations that are defined in the underlying data backend.
Construction
tsk("tiny_imagenet")Download
Thetask's backend is aDataBackendLazy which will download the data once it is requested.Other meta-data is already available before that.You can cache these datasets by setting themlr3torch.cache option toTRUE or to a specific path to be usedas the cache directory.
Properties
Task type: “classif”
Properties: “multiclass”
Has Missings: no
Target: “class”
Features: “image”
Data Dimension: 120000x4
References
Deng, Jia, Dong, Wei, Socher, Richard, Li, Li-Jia, Li, Kai, Fei-Fei, Li (2009).“Imagenet: A large-scale hierarchical image database.”In2009 IEEE conference on computer vision and pattern recognition, 248–255.IEEE.
Examples
task = tsk("tiny_imagenet")Create a Torch Learner from a ModelDescriptor
Description
First ann_graph is created usingmodel_descriptor_to_module and then a learner is created from thismodule and the remaining information from the model descriptor, which must include the optimizer and loss functionand optionally callbacks.
Usage
model_descriptor_to_learner(model_descriptor)Arguments
model_descriptor | ( |
Value
See Also
Other Graph Network:ModelDescriptor(),TorchIngressToken(),mlr_learners_torch_model,mlr_pipeops_module,mlr_pipeops_torch,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,model_descriptor_to_module(),model_descriptor_union(),nn_graph()
Create a nn_graph from ModelDescriptor
Description
Creates thenn_graph from aModelDescriptor. Mostly for internal use, since theModelDescriptor is inmost circumstances harder to use than just creatingnn_graph directly.
Usage
model_descriptor_to_module( model_descriptor, output_pointers = NULL, list_output = FALSE)Arguments
model_descriptor | ( |
output_pointers | ( |
list_output | ( |
Value
See Also
Other Graph Network:ModelDescriptor(),TorchIngressToken(),mlr_learners_torch_model,mlr_pipeops_module,mlr_pipeops_torch,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,model_descriptor_to_learner(),model_descriptor_union(),nn_graph()
Union of ModelDescriptors
Description
This is a mostly internal function that is used inPipeOpTorchs with multiple input channels.
It creates the union of multipleModelDescriptors:
graphs are combinded (if they are not identical to begin with). The first entry'sgraphis modified byreference.PipeOps with the same ID must be identical. No new input edges may be added toPipeOps.Drops
pointer/pointer_shapeentries.The new task is thefeature union of the two incoming tasks.
The
optimizerandlossof bothModelDescriptors must be identical.Ingress tokens and callbacks are merged, where objects with the same
"id"must be identical.
Usage
model_descriptor_union(md1, md2)Arguments
md1 | ( |
md2 | ( |
Details
The requirement that no new input edgedes may be added toPipeOps is not theoretically necessary, but sincewe assume that ModelDescriptor is being built from beginning to end (i.e.PipeOps never get new ancestors) wecan make this assumption and simplify things. Otherwise we'd need to treat "..."-inputs special.)
Value
See Also
Other Graph Network:ModelDescriptor(),TorchIngressToken(),mlr_learners_torch_model,mlr_pipeops_module,mlr_pipeops_torch,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,model_descriptor_to_learner(),model_descriptor_to_module(),nn_graph()
Other Model Configuration:ModelDescriptor(),mlr_pipeops_torch_callbacks,mlr_pipeops_torch_loss,mlr_pipeops_torch_optimizer
Create a Neural Network Layer
Description
Retrieve a neural network layer from themlr_pipeops dictionary.
Usage
nn(.key, ...)Arguments
.key | ( |
... | (any) |
Examples
po1 = po("nn_linear", id = "linear")# is the same as:po2 = nn("linear")CLS Token for FT-Transformer
Description
Concatenates a CLS token to the input as the last feature.The input shape is expected to be(batch, n_features, d_token) and the output shape is(batch, n_features + 1, d_token).
This is used in theLearnerTorchFTTransformer.
Usage
nn_ft_cls(d_token, initialization)Arguments
d_token | ( |
initialization | ( |
References
Devlin, Jacob, Chang, Ming-Wei, Lee, Kenton, Toutanova, Kristina (2018).“Bert: Pre-training of deep bidirectional transformers for language understanding.”arXiv preprint arXiv:1810.04805.
Single Transformer Block for FT-Transformer
Description
A transformer block consisting of a multi-head self-attention mechanism followed by a feed-forwardnetwork.
This is used inLearnerTorchFTTransformer.
Usage
nn_ft_transformer_block( d_token, attention_n_heads, attention_dropout, attention_initialization, ffn_d_hidden = NULL, ffn_d_hidden_multiplier = NULL, ffn_dropout, ffn_activation, residual_dropout, prenormalization, is_first_layer, attention_normalization, ffn_normalization, query_idx = NULL, attention_bias, ffn_bias_first, ffn_bias_second)Arguments
d_token | ( |
attention_n_heads | ( |
attention_dropout | ( |
attention_initialization | ( |
ffn_d_hidden | ( |
ffn_d_hidden_multiplier | ( |
ffn_dropout | ( |
ffn_activation | ( |
residual_dropout | ( |
prenormalization | ( |
is_first_layer | ( |
attention_normalization | ( |
ffn_normalization | ( |
query_idx | ( |
attention_bias | ( |
ffn_bias_first | ( |
ffn_bias_second | ( |
References
Devlin, Jacob, Chang, Ming-Wei, Lee, Kenton, Toutanova, Kristina (2018).“Bert: Pre-training of deep bidirectional transformers for language understanding.”arXiv preprint arXiv:1810.04805.Gorishniy Y, Rubachev I, Khrulkov V, Babenko A (2021).“Revisiting Deep Learning for Tabular Data.”arXiv,2106.11959.
GeGLU Module
Description
This module implements the Gaussian Error Linear Unit Gated Linear Unit (GeGLU) activation function.It computes\text{GeGLU}(x, g) = x \cdot \text{GELU}(g)where \(x\) and \(g\) are created by splitting the input tensor in half along the last dimension.
Usage
nn_geglu()References
Shazeer N (2020).“GLU Variants Improve Transformer.”2002.05202,https://arxiv.org/abs/2002.05202.
Examples
x = torch::torch_randn(10, 10)glu = nn_geglu()glu(x)Graph Network
Description
Represents a neural network using aGraph that contains mostlyPipeOpModules.
Usage
nn_graph(graph, shapes_in, output_map = graph$output$name, list_output = FALSE)Arguments
graph | |
shapes_in | (named |
output_map | ( |
list_output | ( |
Value
Fields
graph::Graph
The graph (consisting primarily ofPipeOpModules) that is wrapped by the network.input_map::character()
The names of the input arguments of the network.shapes_in::list()
The shapes of the input tensors of the network.output_map::character()
Which output elements of the graph are returned by the$forward()method.list_output::logical(1)
Whether the output is a list of tensors.module_list::nn_module_list
The list of modules in the network.list_output::logical(1)
Whether the output is a list of tensors.
See Also
Other Graph Network:ModelDescriptor(),TorchIngressToken(),mlr_learners_torch_model,mlr_pipeops_module,mlr_pipeops_torch,mlr_pipeops_torch_ingress,mlr_pipeops_torch_ingress_categ,mlr_pipeops_torch_ingress_ltnsr,mlr_pipeops_torch_ingress_num,model_descriptor_to_learner(),model_descriptor_to_module(),model_descriptor_union()
Examples
graph = mlr3pipelines::Graph$new()graph$add_pipeop(po("module_1", module = nn_linear(10, 20)), clone = FALSE)graph$add_pipeop(po("module_2", module = nn_relu()), clone = FALSE)graph$add_pipeop(po("module_3", module = nn_linear(20, 1)), clone = FALSE)graph$add_edge("module_1", "module_2")graph$add_edge("module_2", "module_3")network = nn_graph(graph, shapes_in = list(module_1.input = c(NA, 10)))x = torch_randn(16, 10)network(module_1.input = x)Concatenates multiple tensors
Description
Concatenates multiple tensors on a given dimension.No broadcasting rules are applied here, you must reshape the tensors before to have the same shape.
Usage
nn_merge_cat(dim = -1)Arguments
dim | ( |
Product of multiple tensors
Description
Calculates the product of all input tensors.
Usage
nn_merge_prod()Sum of multiple tensors
Description
Calculates the sum of all input tensors.
Usage
nn_merge_sum()ReGLU Module
Description
Rectified Gated Linear Unit (ReGLU) module.Computes the output as\text{ReGLU}(x, g) = x \cdot \text{ReLU}(g)where \(x\) and \(g\) are created by splitting the input tensor in half along the last dimension.
Usage
nn_reglu()References
Shazeer N (2020).“GLU Variants Improve Transformer.”2002.05202,https://arxiv.org/abs/2002.05202.
Examples
x = torch::torch_randn(10, 10)reglu = nn_reglu()reglu(x)Reshape
Description
Reshape a tensor to the given shape.
Usage
nn_reshape(shape)Arguments
shape | ( |
Squeeze
Description
Squeezes a tensor by callingtorch::torch_squeeze() with the given dimensiondim.
Usage
nn_squeeze(dim)Arguments
dim | ( |
Categorical Tokenizer
Description
Tokenizes categorical features into a dense embedding.For an input of shape(batch, n_features) the output shape is(batch, n_features, d_token).
Usage
nn_tokenizer_categ(cardinalities, d_token, bias, initialization)Arguments
cardinalities | ( |
d_token | ( |
bias | ( |
initialization | ( |
References
Gorishniy Y, Rubachev I, Khrulkov V, Babenko A (2021).“Revisiting Deep Learning for Tabular Data.”arXiv,2106.11959.
Numeric Tokenizer
Description
Tokenizes numeric features into a dense embedding.For an input of shape(batch, n_features) the output shape is(batch, n_features, d_token).
Usage
nn_tokenizer_num(n_features, d_token, bias, initialization)Arguments
n_features | ( |
d_token | ( |
bias | ( |
initialization | ( |
References
Gorishniy Y, Rubachev I, Khrulkov V, Babenko A (2021).“Revisiting Deep Learning for Tabular Data.”arXiv,2106.11959.
Unsqueeze
Description
Unsqueezes a tensor by callingtorch::torch_unsqueeze() with the given dimensiondim.
Usage
nn_unsqueeze(dim)Arguments
dim | ( |
Network Output Dimension
Description
Calculates the output dimension of a neural network for a given task that is expected bymlr3torch.For classification, this is the number of classes (unless it is a binary classification task,where it is 1). For regression, it is 1.
Usage
output_dim_for(x, ...)Arguments
x | (any) |
... | (any) |
Create Torch Preprocessing PipeOps
Description
Function to create objects of classPipeOpTaskPreprocTorch in a more convenient way.Start by reading the documentation ofPipeOpTaskPreprocTorch.
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 | ( |
fn | ( |
shapes_out | ( |
param_set | ( |
packages | ( |
rowwise | ( |
parent_env | ( |
stages_init | ( |
tags | ( |
Value
AnR6Class instance inheriting fromPipeOpTaskPreprocTorch
Examples
PipeOpPreprocExample = pipeop_preproc_torch("preproc_example", function(x, a) x + a)po_example = PipeOpPreprocExample$new()po_example$param_setReplace the head of a networkReplaces the head of the network with a linear layer with d_out classes.
Description
Replace the head of a networkReplaces the head of the network with a linear layer with d_out classes.
Usage
replace_head(network, d_out)Arguments
network | ( |
d_out | ( |
Sugar Function for Torch Callback
Description
Retrieves one or moreTorchCallbacks frommlr3torch_callbacks.Works likemlr3::lrn() andmlr3::lrns().
Usage
t_clbk(.key, ...)t_clbks(.keys)Arguments
.key | ( |
... | (any) |
.keys | ( |
Value
list() ofTorchCallbacks
See Also
Other Callback:TorchCallback,as_torch_callback(),as_torch_callbacks(),callback_set(),mlr3torch_callbacks,mlr_callback_set,mlr_callback_set.checkpoint,mlr_callback_set.progress,mlr_callback_set.tb,mlr_callback_set.unfreeze,mlr_context_torch,torch_callback()
Other Torch Descriptor:TorchCallback,TorchDescriptor,TorchLoss,TorchOptimizer,as_torch_callbacks(),as_torch_loss(),as_torch_optimizer(),mlr3torch_losses,mlr3torch_optimizers,t_loss(),t_opt()
Examples
t_clbk("progress")Loss Function Quick Access
Description
Retrieve one or moreTorchLosses frommlr3torch_losses.Works likemlr3::lrn() andmlr3::lrns().
Usage
t_loss(.key, ...)t_losses(.keys, ...)Arguments
.key | ( |
... | (any) |
.keys | ( |
Value
See Also
Other Torch Descriptor:TorchCallback,TorchDescriptor,TorchLoss,TorchOptimizer,as_torch_callbacks(),as_torch_loss(),as_torch_optimizer(),mlr3torch_losses,mlr3torch_optimizers,t_clbk(),t_opt()
Examples
t_loss("mse", reduction = "mean")# get the dictionaryt_loss()t_losses(c("mse", "l1"))# get the dictionaryt_losses()Optimizers Quick Access
Description
Retrieves one or moreTorchOptimizers frommlr3torch_optimizers.Works likemlr3::lrn() andmlr3::lrns().
Usage
t_opt(.key, ...)t_opts(.keys, ...)Arguments
.key | ( |
... | (any) |
.keys | ( |
Value
See Also
Other Torch Descriptor:TorchCallback,TorchDescriptor,TorchLoss,TorchOptimizer,as_torch_callbacks(),as_torch_loss(),as_torch_optimizer(),mlr3torch_losses,mlr3torch_optimizers,t_clbk(),t_loss()
Other Dictionary:mlr3torch_callbacks,mlr3torch_losses,mlr3torch_optimizers
Examples
t_opt("adam", lr = 0.1)# get the dictionaryt_opt()t_opts(c("adam", "sgd"))# get the dictionaryt_opts()Create a Dataset from a Task
Description
Creates a torchdataset from an mlr3Task.The resulting dataset's$.get_batch() method returns a list with elementsx,y andindex:
xis a list with tensors, whose content is defined by the parameterfeature_ingress_tokens.yis the target variable and its content is defined by the parametertarget_batchgetter..indexis the index of the batch in the task's data.
The data is returned on the device specified by the parameterdevice.
Usage
task_dataset(task, feature_ingress_tokens, target_batchgetter = NULL)Arguments
task | |
feature_ingress_tokens | (named |
target_batchgetter | ( |
Value
Examples
task = tsk("iris")sepal_ingress = TorchIngressToken( features = c("Sepal.Length", "Sepal.Width"), batchgetter = batchgetter_num, shape = c(NA, 2))petal_ingress = TorchIngressToken( features = c("Petal.Length", "Petal.Width"), batchgetter = batchgetter_num, shape = c(NA, 2))ingress_tokens = list(sepal = sepal_ingress, petal = petal_ingress)target_batchgetter = function(data) { torch_tensor(data = data[[1L]], dtype = torch_float32())$unsqueeze(2)}dataset = task_dataset(task, ingress_tokens, target_batchgetter)batch = dataset$.getbatch(1:10)batchCreate a Callback Descriptor
Description
Convenience function to create a customTorchCallback.All arguments that are available incallback_set() are also available here.For more information on how to correctly implement a new callback, seeCallbackSet.
Usage
torch_callback( id, classname = paste0("CallbackSet", capitalize(id)), param_set = NULL, packages = NULL, label = capitalize(id), man = NULL, on_begin = NULL, on_end = NULL, on_exit = NULL, on_epoch_begin = NULL, on_before_valid = NULL, on_epoch_end = NULL, on_batch_begin = NULL, on_batch_end = NULL, on_after_backward = NULL, on_batch_valid_begin = NULL, on_batch_valid_end = NULL, on_valid_end = NULL, state_dict = NULL, load_state_dict = NULL, initialize = NULL, public = NULL, private = NULL, active = NULL, parent_env = parent.frame(), inherit = CallbackSet, lock_objects = FALSE)Arguments
id | ( |
classname | ( |
param_set | ( |
packages | ( |
label | ( |
man | ( |
on_begin,on_end,on_epoch_begin,on_before_valid,on_epoch_end,on_batch_begin,on_batch_end,on_after_backward,on_batch_valid_begin,on_batch_valid_end,on_valid_end,on_exit | ( |
state_dict | ( |
load_state_dict | ( |
initialize | ( |
public,private,active | ( |
parent_env | ( |
inherit | ( |
lock_objects | ( |
Value
Internals
It first creates anR6 class inheriting fromCallbackSet (usingcallback_set()) andthen wraps this generator in aTorchCallback that can be passed to a torch learner.
Stages
begin:: Run before the training loop begins.epoch_begin:: Run he beginning of each epoch.batch_begin:: Run before the forward call.after_backward:: Run after the backward call.batch_end:: Run after the optimizer step.batch_valid_begin:: Run before the forward call in the validation loop.batch_valid_end:: Run after the forward call in the validation loop.valid_end:: Run at the end of validation.epoch_end:: Run at the end of each epoch.end:: Run after last epoch.exit:: Run at last, usingon.exit().
See Also
Other Callback:TorchCallback,as_torch_callback(),as_torch_callbacks(),callback_set(),mlr3torch_callbacks,mlr_callback_set,mlr_callback_set.checkpoint,mlr_callback_set.progress,mlr_callback_set.tb,mlr_callback_set.unfreeze,mlr_context_torch,t_clbk()
Examples
custom_tcb = torch_callback("custom", initialize = function(name) { self$name = name }, on_begin = function() { cat("Hello", self$name, ", we will train for ", self$ctx$total_epochs, "epochs.\n") }, on_end = function() { cat("Training is done.") })learner = lrn("classif.torch_featureless", batch_size = 16, epochs = 1, callbacks = custom_tcb, cb.custom.name = "Marie", device = "cpu")task = tsk("iris")learner$train(task)