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

Method __call__

tensorflow/python/layers/base.py:500–569  ·  view source on GitHub ↗

Wraps `call`, applying pre- and post-processing steps. Arguments: inputs: input tensor(s). *args: additional positional arguments to be passed to `self.call`. **kwargs: additional keyword arguments to be passed to `self.call`. **Note**: kwarg `scope` is reserved for us

(self, inputs, *args, **kwargs)

Source from the content-addressed store, hash-verified

498 return variable
499
500 def __call__(self, inputs, *args, **kwargs):
501 """Wraps `call`, applying pre- and post-processing steps.
502
503 Arguments:
504 inputs: input tensor(s).
505 *args: additional positional arguments to be passed to `self.call`.
506 **kwargs: additional keyword arguments to be passed to `self.call`.
507 **Note**: kwarg `scope` is reserved for use by the layer.
508
509 Returns:
510 Output tensor(s).
511
512 Note:
513 - If the layer's `call` method takes a `scope` keyword argument,
514 this argument will be automatically set to the current variable scope.
515 - If the layer's `call` method takes a `mask` argument (as some Keras
516 layers do), its default value will be set to the mask generated
517 for `inputs` by the previous layer (if `input` did come from
518 a layer that generated a corresponding mask, i.e. if it came from
519 a Keras layer with masking support.
520
521 Raises:
522 ValueError: if the layer's `call` method returns None (an invalid value).
523 """
524 scope = kwargs.pop('scope', None)
525
526 if self._keras_style:
527 if scope is not None:
528 raise ValueError(
529 'scope argument not allowed when keras style layers are enabled, '
530 'but saw: {}'.format(scope))
531 return super(Layer, self).__call__(inputs, *args, **kwargs)
532
533 self._set_scope(scope)
534
535 if self.built:
536 try:
537 # Some classes which inherit from Layer do not use its constructor, so
538 # rather than initializing to None we check for an AttributeError.
539 scope_context_manager = self._always_reuse_variable_scope
540 except AttributeError:
541 # From this point we will always set reuse=True, so create a "final"
542 # variable scope with this setting. We avoid re-creating variable scopes
543 # after this point as an optimization.
544 self._always_reuse_variable_scope = vs.variable_scope(
545 self._scope, reuse=True, auxiliary_name_scope=False)
546 scope_context_manager = self._always_reuse_variable_scope
547 else:
548 scope_context_manager = vs.variable_scope(
549 self._scope, reuse=self._reuse, auxiliary_name_scope=False)
550
551 with scope_context_manager as scope:
552 self._current_scope = scope
553
554 try:
555 call_has_scope_arg = self._call_has_scope_arg
556 except AttributeError:
557 self._call_fn_args = function_utils.fn_args(self.call)

Callers

nothing calls this directly

Calls 6

_set_scopeMethod · 0.95
variable_scopeMethod · 0.80
executing_eagerlyMethod · 0.80
popMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected