We used this in the classroom, and our professor said that we can just pass it the correct shape (the comment says: "The list of 1D dimensional float tensor-sizators is the same length as the logits"). This does not help in what they mean, but perhaps it will help you run your code. Worked for me.
This code should do the trick: [tf.ones(batch_size, tf.float32) for _ in logits] .
Edit: from TF code:
for logit, target, weight in zip(logits, targets, weights): if softmax_loss_function is None: # TODO(irving,ebrevdo): This reshape is needed because # sequence_loss_by_example is called with scalars sometimes, which # violates our general scalar strictness policy. target = array_ops.reshape(target, [-1]) crossent = nn_ops.sparse_softmax_cross_entropy_with_logits( logit, target) else: crossent = softmax_loss_function(logit, target) log_perp_list.append(crossent * weight)
Missed weights are multiplied by the loss for this particular logit. Therefore, I assume that if you want to take a specific forecast seriously, you can increase your weight above 1.
source share