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

Class Sqrt

python/singa/autograd.py:2923–2949  ·  view source on GitHub ↗

`y = x^0.5`, is applied to the tensor elementwise.

Source from the content-addressed store, hash-verified

2921
2922
2923class Sqrt(Operator):
2924 """
2925 `y = x^0.5`, is applied to the tensor elementwise.
2926 """
2927
2928 def __init__(self):
2929 super(Sqrt, self).__init__()
2930
2931 def forward(self, x):
2932 """
2933 Return `x^0.5`, where x is CTensor.
2934 """
2935 if training:
2936 self.input = x
2937 return singa.Sqrt(x)
2938
2939 def backward(self, dy):
2940 """
2941 Args:
2942 dy (CTensor): the gradient tensor from upper operations
2943 Returns:
2944 CTensor, the gradient over input
2945 """
2946 dx = singa.PowFloat(self.input, -0.5)
2947 dx = singa.MultFloat(dx, 0.5)
2948 dx = singa.__mul__(dy, dx)
2949 return dx
2950
2951
2952def sqrt(x):

Callers 4

sqrtFunction · 0.70
TEST_FFunction · 0.50
TEST_FFunction · 0.50
TrainFunction · 0.50

Calls

no outgoing calls

Tested by 2

TEST_FFunction · 0.40
TEST_FFunction · 0.40