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

Method forward

python/singa/autograd.py:3007–3023  ·  view source on GitHub ↗

Return `a-b`, where x is CTensor.

(self, a, b)

Source from the content-addressed store, hash-verified

3005 super(Sub, self).__init__()
3006
3007 def forward(self, a, b):
3008 """
3009 Return `a-b`, where x is CTensor.
3010 """
3011 ori_type = None
3012 if a.data_type() != singa.kFloat32:
3013 ori_type = a.data_type()
3014 a = a.AsType(singa.kFloat32)
3015 b = b.AsType(singa.kFloat32)
3016 res = singa.__sub__(a, b)
3017 if ori_type is not None:
3018 res = res.AsType(ori_type)
3019 if training:
3020 self.shape0 = list(a.shape())
3021 self.shape1 = list(b.shape())
3022 self.shape3 = list(res.shape())
3023 return res
3024
3025 def backward(self, dy):
3026 """

Callers

nothing calls this directly

Calls 4

data_typeMethod · 0.80
shapeMethod · 0.80
AsTypeMethod · 0.45
__sub__Method · 0.45

Tested by

no test coverage detected