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

Method backward

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

Source from the content-addressed store, hash-verified

5305 return x
5306
5307 def backward(self, dy):
5308 x_shape = self.x_shape.copy()
5309 for axis, s_1, s_2 in zip(
5310 range(len(self.scales))[::-1], self.scales[::-1],
5311 x_shape[::-1]):
5312 s_1 = int(s_1)
5313 if s_1 != 1:
5314 duplic = s_1
5315 dxs = []
5316 for i in range(s_2):
5317 tmp_tensor = None
5318 for j in range(duplic):
5319 if not tmp_tensor:
5320 tmp_tensor = singa.SliceOn(dy, i * duplic + j,
5321 i * duplic + j + 1, axis)
5322 else:
5323 tmp_tensor += singa.SliceOn(dy, i * duplic + j,
5324 i * duplic + j + 1,
5325 axis)
5326 dxs.append(tmp_tensor)
5327 dxs = singa.VecTensor(dxs)
5328 dy = singa.ConcatOn(dxs, axis)
5329 dy = singa.Reshape(dy, self.x_shape)
5330 return dy
5331
5332
5333def upsample(x, mode, scales):

Callers

nothing calls this directly

Calls 2

appendMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected