| 90 | |
| 91 | |
| 92 | class Activation(Layer): |
| 93 | def __init__(self, name): |
| 94 | self.last_input = None |
| 95 | self.activation = get_activation(name) |
| 96 | # Derivative of activation function |
| 97 | self.activation_d = elementwise_grad(self.activation) |
| 98 | |
| 99 | def forward_pass(self, X): |
| 100 | self.last_input = X |
| 101 | return self.activation(X) |
| 102 | |
| 103 | def backward_pass(self, delta): |
| 104 | return self.activation_d(self.last_input) * delta |
| 105 | |
| 106 | def shape(self, x_shape): |
| 107 | return x_shape |
| 108 | |
| 109 | |
| 110 | class Dropout(Layer, PhaseMixin): |
no outgoing calls