0

I'm using google's seq2seq library and based on some computations that I do between the predictions and the input I would like to zero out some of the losses for certain time steps (not for padding).

What I do is basically to go through each batch then through each time step of the decoder (logits) and for eatc time step I add "a zero or a one" to a list (based on my computation). This list should then be converted to a tensor and multiplied by the losses.

My problem is the shape of the tensor reurned by the sparse_softmax_cross_entropy_with_logits is variable, its not always the shape of the target tensor. So there is a mismatch of dimensions. Has anyone does something like this before and can share it, or know why this happens.

lehar
  • 3
  • 4
  • I don't often use sparse matrices, this seems like a place to use dense matrices, e.g.: `softmax_cross_entropy_with_logits`. No? – David Parks Mar 30 '18 at 19:04
  • Shouldn't the logits and targets have the same shape for softmax_cross_entropy_with_logits? In seq2seq, the have different shapes. – lehar Mar 31 '18 at 14:40
  • Why is it not the same size? Can you clarify what you're doing there? – David Parks Apr 02 '18 at 19:24
  • I don't understand your question. sparse_softmax_cross_entropy_with_logits returns the same shape as the target tensor – Alexandre Passos Apr 05 '18 at 20:21

0 Answers0