yabufarha / ms-tcn

Other
214 stars 58 forks source link

Mask usage #22

Closed kkirtac closed 4 years ago

kkirtac commented 4 years ago

Hi @yabufarha ,

I understand that you are maintaining a binary mask to avoid performing computations for the padded entries.

The second dimension of your mask is indexing class labels: mask = torch.zeros(len(batch_input), self.num_classes, max(length_of_sequences), dtype=torch.float)

I noticed you are indexing only the first class label in your model's forward pass, DilatedResidualLayer, SingleStageModel, MultiStageModel ,

Could you please explain the reason?

Many thanks.

yabufarha commented 4 years ago

No actually here I'm using the broadcasting property in pytorch. It will mask all the elements of that dimension. Maybe I should have set the second dimension of the mask to 1 to avoid confusion.

Just to confirm, I'm masking all elements in the second dimension not only the first one. I'm using [:, 0:1, :] to index the mask to make sure that the 2nd dimension is 1, which is required for broadcasting. I'm relying on broadcasting as all elements in that dimension have the same mask, and this mask is used to mask predicted probabilities (see the smoothing loss) where the second dimension equals num_class, and also to mask features (as in the lines you referred to) where the second dimension equals the number of feature maps.

I hope this would resolve the confusion.