Args: dy (CTensor): the gradient tensor from upper operations Returns: CTensor, the gradient over input
(self, dy)
| 1939 | return out |
| 1940 | |
| 1941 | def backward(self, dy): |
| 1942 | """ |
| 1943 | Args: |
| 1944 | dy (CTensor): the gradient tensor from upper operations |
| 1945 | Returns: |
| 1946 | CTensor, the gradient over input |
| 1947 | """ |
| 1948 | dx = singa.__mul__(self.cache[0], self.cache[0]) |
| 1949 | dx = singa.MultFloat(dx, -1.0) |
| 1950 | dx = singa.AddFloat(dx, 1.0) |
| 1951 | dx *= dy |
| 1952 | return dx |
| 1953 | |
| 1954 | |
| 1955 | def tanh(x): |