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

Function _grad_fn

tensorflow/contrib/layers/python/layers/rev_block_lib.py:604–622  ·  view source on GitHub ↗
(output_grads, variables=None)

Source from the content-addressed store, hash-verified

602 original_vars = set(tape.watched_variables())
603
604 def _grad_fn(output_grads, variables=None):
605 # Validate that custom_gradient passes the right variables into grad_fn.
606 if original_vars:
607 assert variables, ("Fn created variables but the variables were not "
608 "passed to the gradient fn.")
609 if set(variables) != original_vars:
610 raise ValueError(_WRONG_VARS_ERR)
611
612 return _recomputing_grad_fn(
613 compute_fn=fn,
614 original_args=args,
615 original_vars=original_vars,
616 output_grads=output_grads,
617 grad_fn_variables=variables,
618 use_data_dep=use_data_dep_,
619 tupleize_grads=tupleize_grads,
620 arg_scope=arg_scope,
621 var_scope=vs,
622 has_is_recompute_kwarg=has_is_recompute_kwarg)
623
624 # custom_gradient inspects the signature of the function to determine
625 # whether the user expects variables passed in the grad_fn. If the function

Callers 1

grad_fnFunction · 0.70

Calls 1

_recomputing_grad_fnFunction · 0.85

Tested by

no test coverage detected