Rejects a computed output size that no tensor can have, i.e. one that is not a positive number.
Operators such as convolutions and pooling compute their spatial output sizes from kernel_size,
stride, padding and dilation, a combination of which can produce a size of zero or less.
Unknown (NA) sizes are accepted, since nothing can be said about them.
Arguments
- extent
(
numeric())
The sizes an operator computed for the dimensions it changes, e.g. the spatial dimensions of a convolution.- shape_in
(
integer())
The input shape, used for the error message.- id
(
character(1)|NULL)
The id of thePipeOp, which the error message names.NULLwhen the assertion is not made for aPipeOp.
See also
Other Shape Assertions:
assert_dim_in_range(),
assert_known_dims(),
assert_ndim(),
assert_not_batch_dim(),
assert_same_batch_size(),
assert_same_ndim(),
assert_shape(),
assert_shapes()
Examples
assert_positive_extent(c(30, NA), c(NA, 3, 32, 32), id = "nn_conv2d")
try(assert_positive_extent(c(0, 4), c(NA, 3, 32, 32), id = "nn_conv2d"))
#> Error : PipeOp 'nn_conv2d' cannot be applied to the input shape (NA,3,32,32): it would produce an output of size 0, 4, which no tensor can have. Check 'kernel_size', 'stride', 'padding' and 'dilation'.