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

Class Acosh

python/singa/autograd.py:2100–2133  ·  view source on GitHub ↗

Calculates the hyperbolic arccosine of the given input tensor element-wise.

Source from the content-addressed store, hash-verified

2098
2099
2100class Acosh(Operator):
2101 """
2102 Calculates the hyperbolic arccosine of the given input tensor element-wise.
2103 """
2104
2105 def __init__(self):
2106 super(Acosh, self).__init__()
2107
2108 def forward(self, x):
2109 """
2110 Args:
2111 x (CTensor): Input tensor
2112 Returns:
2113 CTensor, the output
2114 """
2115 if training:
2116 self.input = x
2117 return singa.Acosh(x)
2118
2119 def backward(self, dy):
2120 """
2121 Args:
2122 dy (CTensor): the gradient tensor from upper operations
2123 Returns:
2124 CTensor, the gradient over input
2125 """
2126 dx = singa.SubFloat(self.input, 1.0)
2127 dx = singa.Sqrt(dx)
2128 temp = singa.AddFloat(self.input, 1.0)
2129 temp = singa.Sqrt(temp)
2130 dx = singa.__mul__(dx, temp)
2131 dx = singa.PowFloat(dx, -1.0)
2132 dx *= dy
2133 return dx
2134
2135
2136def acosh(x):

Callers 1

acoshFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected