-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Batch dim tag special handling can be problematic #920
Comments
@Zettelkasten any thoughts on this? |
Seems reasonable to me to treat different batch dims (e.g. with different packing format) different. |
One reason batch dim was kind of treated always as equal is that in the case it included also the beam, this logic of resolving the beam and making sure all inputs would end up in the same beam was handled separately, so this was a valid assumption. However, when it contains other things (merge dim with some other dim), or is packed (flatten batch), this is not the case, and probably we also don't want that it automatically makes them equal. |
Maybe the equality should exactly cover that: Ignore any contained beam but otherwise check |
For the contrastive loss implementation (#918), we flatten the masked encoder frames via
FlattenBatchLayer
and end up withB&Packed{'input_masked_frames:masked:time'}
batch dim. For all those frames, we want to create a fixed number K=10 of candidate samples. So the natural way would be to useRandIntLayer
and specifyshape=[packed_batch_dim, samples_dim]
withsamples_dim = SpatialDim(..., K)
. However, that does not work becausepacked_batch_dim
can not be different from the normal batch dim. This is by the current definition of equality of dim tags (#634).The workaround in #918 is to first change the packed batch dim to a spatial dim via
ReinterpretDataLayer
, thenRandIntLayer
works, and later convert it back viaReinterpretDataLayer
to a batch dim, andReinterpretDataLayer
got another new optionbatch_base
where the batch dim is taken from. This is ugly obviously.So I question whether our equality exception for the batch dim (#634) makes sense or maybe should be changed such that it behaves just as any other normal dim tag.
The text was updated successfully, but these errors were encountered: