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

Function _is_trainable

tensorflow/python/ops/while_v2.py:518–533  ·  view source on GitHub ↗

Returns whether the given tensor is trainable.

(tensor)

Source from the content-addressed store, hash-verified

516
517
518def _is_trainable(tensor):
519 """Returns whether the given tensor is trainable."""
520 if not gradients_util.IsTrainable(tensor):
521 return False
522
523 # Special case: untrainable accumulator output. The gradients algorithm
524 # doesn't know about tensor lists of untrainable elements. In theory the
525 # tensor list gradient functions should return None as appropriate, but
526 # because we can't return None from the gradient function we filter out
527 # untrainable accumulator output here to avoid computing the gradient at all.
528 if tensor.op.type == "TensorListPopBack" and tensor.value_index == 0:
529 assert tensor.dtype == dtypes.variant
530 element_type = tensor.op.get_attr("element_dtype")
531 return gradients_util.IsTrainable(element_type)
532
533 return True
534
535
536# TODO(srbs): Pull this into common utils for cond_v2 and while_v2.

Callers 1

_preprocess_gradFunction · 0.85

Calls 1

get_attrMethod · 0.45

Tested by

no test coverage detected