Guest User

Untitled

a guest
Jan 22nd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import chainer
  2. import chainer.links as L
  3. import chainer.functions as F
  4.  
  5. class Build_Network(chainer.Chain):
  6. """Neural Network definition, Multi Layer Perceptron"""
  7. def __init__(self, neuron_units, neuron_units_out):
  8. super(Build_Network, self).__init__()
  9. with self.init_scope():
  10. # the size of the inputs to each layer will be inferred when `None`
  11. self.l1 = L.Linear(None, neuron_units) # n_in -> n_units
  12. self.l2 = L.Linear(None, neuron_units) # n_units -> n_units
  13. self.l3 = L.Linear(None, neuron_units_out) # n_units -> n_out
  14.  
  15. def __call__(self, x):
  16. h1 = F.relu(self.l1(x) ) #passing data x through l1 and applying relu activation fn
  17. h2 = F.relu(self.l2(h1)) #passing output of previous layer (h1) through l2 and applying relu
  18. h3 = self.l3(h2) #passing output of previous layer (h2) through l3
  19. return h3
Add Comment
Please, Sign In to add comment