Skip to contents

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.

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"))
#> Error : PipeOp 'nn_squeeze' would change dimension 1 of the input shape (NA,3,8), which is the batch dimension.