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 a Task and fed into an entry point of the neural network. It is stored as the ingress field in a ModelDescriptor.
TorchIngressToken(features, batchgetter, shape)
Arguments
features: (character)
Features on which the batchgetter will operate.
batchgetter: (function)
Function with two arguments: data and device. This function is given the output of Task$data(rows = batch_indices, cols = features)
and it should produce a tensor of shape shape_out.
shape: (integer)
Shape that batchgetter will produce. Batch-dimension should be included as NA.
Returns
TorchIngressToken object.
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_dt
batch_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_token