Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Softmax:
- # ...
- def forward(self, input):
- '''
- Performs a forward pass of the softmax layer using the given input.
- Returns a 1d numpy array containing the respective probability values.
- - input can be any array with any dimensions.
- '''
- self.last_input_shape = input.shape
- input = input.flatten()
- self.last_input = input
- input_len, nodes = self.weights.shape
- totals = np.dot(input, self.weights) + self.biases
- self.last_totals = totals
- exp = np.exp(totals)
- return exp / np.sum(exp, axis=0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement