Args: dy (CTensor): dL / dy Returns: dx (CTensor): dL / dx
(self, dy)
| 1028 | return x1 |
| 1029 | |
| 1030 | def backward(self, dy): |
| 1031 | """ |
| 1032 | Args: |
| 1033 | dy (CTensor): dL / dy |
| 1034 | Returns: |
| 1035 | dx (CTensor): dL / dx |
| 1036 | """ |
| 1037 | dx1mask = singa.LEFloat(self.input, 0.0) |
| 1038 | dx1 = singa.MultFloat(singa.Exp(self.input), self.gamma * self.alpha) |
| 1039 | dx1 = singa.__mul__(dx1mask, dx1) |
| 1040 | |
| 1041 | dx2mask = singa.GTFloat(self.input, 0.0) |
| 1042 | dx2 = singa.MultFloat(dx2mask, self.gamma) |
| 1043 | |
| 1044 | dx = singa.__add__(dx1, dx2) |
| 1045 | dx *= dy |
| 1046 | return dx |
| 1047 | |
| 1048 | |
| 1049 | def selu(x, alpha=1.67326, gamma=1.0507): |