get_batch_size: Extract the Batch Size for a Given Phase

View source: R/paramset_torchlearner.R

get_batch_sizeR Documentation

Extract the Batch Size for a Given Phase

Description

A LearnerTorch uses the batch_size parameter for both training and prediction, unless batch_size_predict is set, which then takes precedence during prediction. This helper resolves the batch size for one phase and is useful when overwriting the private .dataloader() method of a LearnerTorch.

Usage

get_batch_size(param_vals, phase)

Arguments

param_vals

(named list())
The parameter values, containing batch_size and/or batch_size_predict.

phase

(character(1))
Either "train" or "predict".

Value

(integer(1) or NULL)
The batch size for the given phase or NULL if none is set.

Examples

get_batch_size(list(batch_size = 16), "train")
get_batch_size(list(batch_size = 16, batch_size_predict = 32), "predict")
get_batch_size(list(batch_size_predict = 32), "train")

mlr3torch documentation built on Oct. 30, 2026, 5:10 p.m.