assert_not_batch_dim: Assert that a Dimension is not the Batch Dimension

View source: R/shape.R

assert_not_batch_dimR Documentation

Assert that a Dimension is not the Batch Dimension

Description

Rejects an operation on the first dimension, which is the batch dimension. An operator that changes it would silently change the number of observations, which fails much later with a mismatch against the target.

Usage

assert_not_batch_dim(dim, shape, id)

Arguments

dim

(integer(1))
The resolved dimension that the operator changes, see resolve_dim().

shape

(integer())
The input shape, used for the error message.

id

(character(1))
The id of the PipeOp, which the error message names.

Value

The dimension, invisibly.

See Also

Other Shape Assertions: assert_dim_in_range(), assert_known_dims(), assert_ndim(), assert_positive_extent(), assert_same_batch_size(), assert_same_ndim(), assert_shape(), assert_shapes()

Examples

assert_not_batch_dim(2L, c(NA, 3, 8), id = "nn_squeeze")
try(assert_not_batch_dim(1L, c(NA, 3, 8), id = "nn_squeeze"))

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