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

Method get_losses_for

tensorflow/python/keras/engine/base_layer.py:1390–1407  ·  view source on GitHub ↗

Retrieves losses relevant to a specific set of inputs. Arguments: inputs: Input tensor or list/tuple of input tensors. Returns: List of loss tensors of the layer that depend on `inputs`.

(self, inputs)

Source from the content-addressed store, hash-verified

1388 return [u for u in updates if u in reachable]
1389
1390 def get_losses_for(self, inputs):
1391 """Retrieves losses relevant to a specific set of inputs.
1392
1393 Arguments:
1394 inputs: Input tensor or list/tuple of input tensors.
1395
1396 Returns:
1397 List of loss tensors of the layer that depend on `inputs`.
1398 """
1399 if inputs is None:
1400 # Requesting unconditional losses.
1401 return [l for l in self.losses if l._unconditional_loss]
1402
1403 # Requesting input-conditional losses.
1404 losses = [l for l in self.losses if not l._unconditional_loss]
1405 inputs = nest.flatten(inputs)
1406 reachable = tf_utils.get_reachable_from_inputs(inputs, losses)
1407 return [l for l in losses if l in reachable]
1408
1409 def get_input_mask_at(self, node_index):
1410 """Retrieves the input mask tensor(s) of a layer at a given node.

Calls 1

flattenMethod · 0.45