comparison mlp.py @ 175:e9a95e19e6f8

Added a Print Op
author Yoshua Bengio <bengioy@iro.umontreal.ca>
date Tue, 13 May 2008 15:11:24 -0400
parents ae5651a3696b
children 9911d2cc3c01
comparison
equal deleted inserted replaced
172:fb4837eed1a6 175:e9a95e19e6f8
7 7
8 from learner import * 8 from learner import *
9 from theano import tensor as t 9 from theano import tensor as t
10 from nnet_ops import * 10 from nnet_ops import *
11 import math 11 import math
12 12 from misc import *
13 13
14 class OneHiddenLayerNNetClassifier(OnlineGradientTLearner): 14 class OneHiddenLayerNNetClassifier(OnlineGradientTLearner):
15 """ 15 """
16 Implement a straightforward classicial feedforward 16 Implement a straightforward classicial feedforward
17 one-hidden-layer neural net, with L2 regularization. 17 one-hidden-layer neural net, with L2 regularization.
86 self._W2 = t.matrix('W2') 86 self._W2 = t.matrix('W2')
87 self._b1 = t.row('b1') 87 self._b1 = t.row('b1')
88 self._b2 = t.row('b2') 88 self._b2 = t.row('b2')
89 self._regularization_term = self._L2_regularizer * (t.sum(self._W1*self._W1) + t.sum(self._W2*self._W2)) 89 self._regularization_term = self._L2_regularizer * (t.sum(self._W1*self._W1) + t.sum(self._W2*self._W2))
90 self._output_activations =self._b2+t.dot(t.tanh(self._b1+t.dot(self._input,self._W1.T)),self._W2.T) 90 self._output_activations =self._b2+t.dot(t.tanh(self._b1+t.dot(self._input,self._W1.T)),self._W2.T)
91 self._nll,self._output = crossentropy_softmax_1hot(self._output_activations,self._target_vector) 91 self._nll,self._output = crossentropy_softmax_1hot(Print("output_activations")(self._output_activations),self._target_vector)
92 self._output_class = t.argmax(self._output,1) 92 self._output_class = t.argmax(self._output,1)
93 self._class_error = t.neq(self._output_class,self._target_vector) 93 self._class_error = t.neq(self._output_class,self._target_vector)
94 self._minibatch_criterion = self._nll + self._regularization_term / t.shape(self._input)[0] 94 self._minibatch_criterion = self._nll + self._regularization_term / t.shape(self._input)[0]
95 OnlineGradientTLearner.__init__(self) 95 OnlineGradientTLearner.__init__(self)
96 96