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

Function _GatherGrad

tensorflow/python/ops/resource_variable_ops.py:1876–1886  ·  view source on GitHub ↗

Gradient for gather op.

(op, grad)

Source from the content-addressed store, hash-verified

1874
1875@ops.RegisterGradient("ResourceGather")
1876def _GatherGrad(op, grad):
1877 """Gradient for gather op."""
1878 # Build appropriately shaped IndexedSlices
1879 handle = op.inputs[0]
1880 indices = op.inputs[1]
1881 params_shape = variable_shape(handle)
1882 size = array_ops.expand_dims(array_ops.size(indices), 0)
1883 values_shape = array_ops.concat([size, params_shape[1:]], 0)
1884 values = array_ops.reshape(grad, values_shape)
1885 indices = array_ops.reshape(indices, size)
1886 return (ops.IndexedSlices(values, indices, params_shape), None)
1887
1888
1889def _to_proto_fn(v, export_scope=None):

Callers

nothing calls this directly

Calls 5

variable_shapeFunction · 0.85
reshapeMethod · 0.80
expand_dimsMethod · 0.45
sizeMethod · 0.45
concatMethod · 0.45

Tested by

no test coverage detected