Ensure that a specific dimension is known, i.e. not NA.
Arguments
- shape
(
integer())
The input shape.- dims
(
integer())
Indices of the dimensions that must be known.- what
(
character(1))
Describes those dimensions in the error message, e.g."the channel dimension (dimension 2)".- id
(
character(1)|NULL)
The id of thePipeOpthe assertion is made for, which the error message names.NULLwhen the assertion is not made for aPipeOp.
See also
Other Shape Assertions:
assert_dim_in_range(),
assert_ndim(),
assert_not_batch_dim(),
assert_positive_extent(),
assert_same_batch_size(),
assert_same_ndim(),
assert_shape(),
assert_shapes()
Examples
# a convolution needs the number of input channels, but not the spatial extent
assert_known_dims(c(NA, 3, NA, NA), 2, "the number of channels", id = "nn_conv2d")
try(assert_known_dims(c(NA, NA, 10, 10), 2, "the number of channels", id = "nn_conv2d"))
#> Error : PipeOp 'nn_conv2d' requires the number of channels of the input shape to be known, but got shape (NA,NA,10,10).