| get_batch_constructor | R Documentation |
Returns the function that builds a whole batch of a task, i.e. both the features x and the
target y.
This is how task_dataset loads its batches.
The returned function takes the arguments
data, a data.table with the feature and target columns of the
batch, and
cache, a rather internal hashtab that can be used as a cache when loading multiple
lazy_tensor columns.
It returns a list() with elements x (a named list() of
torch_tensors) and y (a torch_tensor or
NULL).
The default method applies the ingress tokens to obtain x and the target batchgetter to obtain
y.
get_batch_constructor(
task,
feature_ingress_tokens,
target_batchgetter = NULL,
...
)
task |
( |
feature_ingress_tokens |
(named |
target_batchgetter |
( |
... |
(any) |
function(data, cache) -> list(x = list<torch_tensor>, y = torch_tensor | NULL)
task = tsk("iris")
token = TorchIngressToken(task$feature_names, batchgetter_num, c(NA, 4))
# the token's features are a `Selector`; `task_dataset()` resolves them for you
token$features = token$features(task)
batch_constructor = get_batch_constructor(
task,
feature_ingress_tokens = list(input = token),
target_batchgetter = get_target_batchgetter(task)
)
batch = batch_constructor(data = task$data(rows = 1:2))
batch$x$input
batch$y
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.