Skip to content

Commit

Permalink
Update losses.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Avsecz authored Jun 4, 2021
1 parent b9ec3e9 commit 49f3af1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bpnet/losses.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ def multinomial_nll(true_counts, logits):
dist = tf.contrib.distributions.Multinomial(total_count=counts_per_example,
logits=logits_perm)

# get the sequence length for normalization
seqlen = tf.to_float(tf.shape(true_counts)[0])
# Normalize by batch size. NOTE: In the paper we say that
# the loss is normalized by sequence length.
batch_size = tf.to_float(tf.shape(true_counts)[0])

return -tf.reduce_sum(dist.log_prob(true_counts_perm)) / seqlen
return -tf.reduce_sum(dist.log_prob(true_counts_perm)) / batch_size


@gin.configurable
Expand Down

0 comments on commit 49f3af1

Please sign in to comment.