| shape_to_str | R Documentation |
Helpers for writing the private$.shapes_out() method of a PipeOpTorch. They all propagate
unknown (NA) dimensions, see the "Shape Inference" section of PipeOpTorch for the shape conventions.
shape_to_str(x)
broadcast_shapes(shapes, id)
resolve_dim(dim, shape, insert = FALSE)
x |
( |
shapes |
( |
id |
( |
dim |
( |
shape |
( |
insert |
( |
broadcast_shapes() applies the broadcasting rules of torch, generalized to shapes that may
contain NA. Per dimension a known size that is not 1 wins; if all known sizes are 1 and some
input is unknown, the result is unknown, because the unknown one may be greater than 1 and
would then determine the size. The shapes must already have the same number of dimensions:
shorter ones are not left-padded with 1s, because the first dimension is the batch dimension.
resolve_dim() resolves dimension indices that count from the end, as in torch, to positive
ones. Indices that are out of range stay out of range, so that
assert_dim_in_range() reports them.
shape_to_str() formats a shape, or a list() of them, for an error message.
broadcast_shapes() returns an integer() shape, resolve_dim() an integer() of the same
length as dim, and shape_to_str() a character(1).
Other Shape Inference:
infer_shapes(),
reshape_output_shape()
broadcast_shapes(list(c(NA, 1), c(NA, 6)), id = "nn_merge_sum")
resolve_dim(-1, c(NA, 3, 8))
shape_to_str(c(NA, 3, 8))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.