Skip to content
New issue

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

K.mean() in computing loss doesn't make any sense. #20

Open
mayurnewase opened this issue Feb 8, 2019 · 0 comments
Open

K.mean() in computing loss doesn't make any sense. #20

mayurnewase opened this issue Feb 8, 2019 · 0 comments

Comments

@mayurnewase
Copy link

mayurnewase commented Feb 8, 2019

In

def get_loss(args):
           y_pred, y_true = args
           y_true = tf.cast(y_true, 'int32')
           loss = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=y_true, logits=y_pred)
           mask = tf.cast(tf.not_equal(y_true, 0), 'float32')
           loss = tf.reduce_sum(loss * mask, -1) / tf.reduce_sum(mask, -1)
           loss = K.mean(loss)
           return loss

loss = tf.reduce_sum(loss * mask, -1) / tf.reduce_sum(mask, -1)
produce single element, it's mean doesn't make difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant