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
Calls nn_tokenizer_categ() when trained where the parameter cardinalities 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 see PipeOpTorch.
Super classes
mlr3pipelines::PipeOp -> PipeOpTorch -> PipeOpTorchTokenizerCateg
Methods
PipeOpTorchTokenizerCateg$new()
Creates a new instance of this R6 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 would otherwise be set during construction.
Examples
# Construct the PipeOp
pipeop = nn("tokenizer_categ", d_token = 10)
pipeop
#>
#> ── PipeOp <tokenizer_categ>: not trained ───────────────────────────────────────
#> Values: d_token=10, bias=TRUE, initialization=uniform
#>
#> ── Input channels:
#> name train predict
#> <char> <char> <char>
#> input ModelDescriptor Task
#>
#> ── Output channels:
#> name train predict
#> <char> <char> <char>
#> output ModelDescriptor Task
# The available parameters
pipeop$param_set
#> <ParamSet(4)>
#> id class lower upper nlevels default value
#> <char> <char> <num> <num> <num> <list> <list>
#> 1: d_token ParamInt 1 Inf Inf <NoDefault[0]> 10
#> 2: bias ParamLgl NA NA 2 <NoDefault[0]> TRUE
#> 3: initialization ParamFct NA NA 2 <NoDefault[0]> uniform
#> 4: cardinalities ParamUty NA NA Inf <NoDefault[0]> [NULL]