You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def add_loss(self, loss):
...
# Eager only.
losses = tree.flatten(loss)
...
if backend.in_stateless_scope():
scope = backend.get_stateless_scope()
if scope.collect_losses:
for x in losses:
scope.add_loss(loss)
self._loss_ids.add(id(loss))
else:
...
loss is the input, losses are flattened, x is for looping losses, but scope.add_loss and _loss_ids.add are repeatedly adding loss, not x? it'd be wrong if loss is a list of scalar tensor, no?
I am reading this line not believing my eyes:
https://github.com/keras-team/keras/blob/master/keras/src/layers/layer.py#L1205-L1207
loss is the input, losses are flattened, x is for looping losses, but scope.add_loss and _loss_ids.add are repeatedly adding loss, not x? it'd be wrong if loss is a list of scalar tensor, no?
unittests are not covering the loss as a list of scalar tensor cases, https://github.com/keras-team/keras/blob/master/keras/src/layers/layer_test.py#L540-L567
The text was updated successfully, but these errors were encountered: