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

Method Grad

tensorflow/python/framework/function_test.py:1730–1742  ·  view source on GitHub ↗
(x, y0)

Source from the content-addressed store, hash-verified

1728
1729 @function.Defun()
1730 def Grad(x, y0):
1731 if use_forward_func:
1732 y = Model(x)
1733 else:
1734 y = _Model(x)
1735 loss = math_ops.reduce_mean(
1736 math_ops.reduce_sum(y0 * math_ops.log(y), 1), 0)
1737 arg_w, arg_b = function.get_extra_args()
1738 self.assertEqual(arg_w.get_shape(), tensor_shape.TensorShape([64, 64]))
1739 self.assertEqual(arg_b.get_shape(), tensor_shape.TensorShape([64]))
1740 dw, db = gradients_impl.gradients(loss, [arg_w, arg_b])
1741 cvars.extend(function.get_extra_vars())
1742 return loss, dw, db
1743
1744 g = ops.Graph()
1745 with g.as_default():

Callers

nothing calls this directly

Calls 7

_ModelClass · 0.85
reduce_meanMethod · 0.80
reduce_sumMethod · 0.80
ModelClass · 0.50
logMethod · 0.45
get_shapeMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected