SHARE
TWEET

Untitled

a guest Jun 18th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Softmax:
  2.   # ...
  3.  
  4.   def forward(self, input):
  5.     '''
  6.     Performs a forward pass of the softmax layer using the given input.
  7.     Returns a 1d numpy array containing the respective probability values.
  8.     - input can be any array with any dimensions.
  9.     '''
  10.     self.last_input_shape = input.shape
  11.  
  12.     input = input.flatten()
  13.     self.last_input = input
  14.  
  15.     input_len, nodes = self.weights.shape
  16.  
  17.     totals = np.dot(input, self.weights) + self.biases
  18.     self.last_totals = totals
  19.  
  20.     exp = np.exp(totals)
  21.     return exp / np.sum(exp, axis=0)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top