We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
one_hot_labels = tf.one_hot(labels, depth=num_labels, dtype=tf.float32) per_example_loss = -tf.reduce_sum(one_hot_labels * log_probs, axis=-1) loss = tf.reduce_sum(per_example_loss) probabilities = tf.nn.softmax(logits, axis=-1)
log_prob是[batch_size, max_seq, label_num]维度, max_seq有pad,直接reduce_sum全部作为loss?
The text was updated successfully, but these errors were encountered:
这里可以 在计算loss的时候将padding部分mask掉。
不过当时写的时候因为padding部分idx 为 0,所以在计算loss的时候影响不太大,就没考虑mask.
Sorry, something went wrong.
这里可以 在计算loss的时候将padding部分mask掉。 不过当时写的时候因为padding部分idx 为 0,所以在计算loss的时候影响不太大,就没考虑mask. @xuanzebi 您好, 为什么padding部分的label id=0,在计算loss的时候影响不大?这时one-hot标签向量第0维是1吧
不过当时写的时候因为padding部分idx 为 0,所以在计算loss的时候影响不太大,就没考虑mask. @xuanzebi 您好, 为什么padding部分的label id=0,在计算loss的时候影响不大?这时one-hot标签向量第0维是1吧
No branches or pull requests
one_hot_labels = tf.one_hot(labels, depth=num_labels, dtype=tf.float32)
per_example_loss = -tf.reduce_sum(one_hot_labels * log_probs, axis=-1)
loss = tf.reduce_sum(per_example_loss)
probabilities = tf.nn.softmax(logits, axis=-1)
log_prob是[batch_size, max_seq, label_num]维度, max_seq有pad,直接reduce_sum全部作为loss?
The text was updated successfully, but these errors were encountered: