Skip to content

Data verify_out_shape not intuitive when there are implicit dims #1153

@albertz

Description

@albertz

(I use returnn-common code here but nothing is really specific about returnn-common. nn.zeros is just ConstantLayer.)

Consider this code:

x = nn.zeros((dim1, dim2))
x.verify_out_shape({dim1, dim2})

This is correct when dim1 and dim2 are static dims.

Once they are dynamic dims and introduce implicit dims, the verify_out_shape fails because it does not cover the implicit dims. E.g. when dim1 has a dyn_size_ext of shape [B], then currently you actually need:

x.verify_out_shape({dim1, dim2, batch_dim})

Or:

x.verify_out_shape({dim1, dim2, ImplicitDynSizeDim(batch_dim)})

Because the batch dim is an implicit dim.

Why do we have implicit dims? What are those? They were introduced mostly for CumConcatLayer. See #391, #589.

Example of such error: rwth-i6/returnn_common#226

See also the earlier discussion on the introduction of out_shape and verify_out_shape: #706, #757

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions