Parse a tensor shape to dictionary mapping axes names to their lengths.
Source:R/parse_shape.R
parse_shape.Rd
Use underscore to skip the dimension in parsing.
Examples
if (requireNamespace("abind", quietly = TRUE)) {
# Use underscore to skip the dimension in parsing.
x <- array(0, dim = c(2, 3, 5, 7))
parse_shape(x, 'batch _ h w')
# `parse_shape` output can be used to specify axes_lengths for other
# operations:
y <- array(0, dim = 700)
shape_info <- parse_shape(x, 'b _ h w')
# rearrange(y, '(b c h w) -> b c h w', shape_info) would give shape
# (2, 10, 5, 7)
}