MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / add_loss

Method add_loss

tensorflow/python/layers/base.py:282–297  ·  view source on GitHub ↗
(self, losses, inputs=None)

Source from the content-addressed store, hash-verified

280 return self._scope.name
281
282 def add_loss(self, losses, inputs=None):
283 previous_losses_length = len(self._losses)
284 previous_callable_losses_length = len(self._callable_losses)
285 super(Layer, self).add_loss(losses, inputs=inputs)
286 if not context.executing_eagerly():
287 # TODO(fchollet): deprecate collection below.
288 new_losses = self._losses[previous_losses_length:]
289 new_callable_losses = self._callable_losses[
290 previous_callable_losses_length:]
291 for regularizer in new_callable_losses:
292 loss_tensor = regularizer()
293 if loss_tensor is not None:
294 new_losses.append(loss_tensor)
295 _add_elements_to_collection(
296 new_losses,
297 ops.GraphKeys.REGULARIZATION_LOSSES)
298
299 def _name_scope(self):
300 """Determines op naming for the Layer."""

Callers 4

compute_weighted_lossFunction · 0.45
buildMethod · 0.45
callMethod · 0.45

Calls 3

executing_eagerlyMethod · 0.80
appendMethod · 0.45

Tested by 2

buildMethod · 0.36
callMethod · 0.36