`y = exp(x)`, is applied to the tensor elementwise.
| 2697 | |
| 2698 | |
| 2699 | class Exp(Operator): |
| 2700 | """ |
| 2701 | `y = exp(x)`, is applied to the tensor elementwise. |
| 2702 | """ |
| 2703 | |
| 2704 | def forward(self, a): |
| 2705 | """ |
| 2706 | Return `exp(a)`, where a is Tensor. |
| 2707 | """ |
| 2708 | if training: |
| 2709 | self.input = a |
| 2710 | return singa.Exp(a) |
| 2711 | |
| 2712 | def backward(self, dy): |
| 2713 | """ |
| 2714 | Args: |
| 2715 | dy (CTensor): the gradient tensor from upper operations |
| 2716 | Returns: |
| 2717 | CTensor, the gradient over input |
| 2718 | """ |
| 2719 | dx = singa.Exp(self.input) |
| 2720 | dx *= dy |
| 2721 | return dx |
| 2722 | |
| 2723 | |
| 2724 | def exp(a): |