MCPcopy Create free account
hub / github.com/apache/singa / backward

Method backward

python/singa/autograd.py:1528–1540  ·  view source on GitHub ↗
(self, dy)

Source from the content-addressed store, hash-verified

1526 return y.data
1527
1528 def backward(self, dy):
1529 mask = np.ones(dy.shape(), dtype=np.float32)
1530 u_shape = self.updates.shape
1531 for i in range(u_shape[0]):
1532 for j in range(u_shape[1]):
1533 idx = int(self.indices[i][j])
1534 if self.axis == 0:
1535 mask[idx][j] = 0.
1536 else:
1537 mask[i][idx] = 0.
1538 mask = tensor.from_numpy(mask)
1539 mask.to_device(dy.device())
1540 return singa.__mul__(dy, mask.data)
1541
1542
1543def scatter_elements(x, indices, updates, axis=0):

Callers

nothing calls this directly

Calls 4

shapeMethod · 0.80
deviceMethod · 0.80
to_deviceMethod · 0.45
__mul__Method · 0.45

Tested by

no test coverage detected