comparison baseline/log_reg/log_reg.py @ 199:777f48ba30df

Add MSE cost to log_reg.py
author Arnaud Bergeron <abergeron@gmail.com>
date Tue, 02 Mar 2010 18:43:54 -0500
parents 5d88ed99c0af
children 7be1f086a89e
comparison
equal deleted inserted replaced
198:5d88ed99c0af 199:777f48ba30df
110 # LP[T.arange(y.shape[0]),y] is a vector v containing [LP[0,y[0]], LP[1,y[1]], LP[2,y[2]], ..., LP[n-1,y[n-1]]] 110 # LP[T.arange(y.shape[0]),y] is a vector v containing [LP[0,y[0]], LP[1,y[1]], LP[2,y[2]], ..., LP[n-1,y[n-1]]]
111 # and T.mean(LP[T.arange(y.shape[0]),y]) is the mean (across minibatch examples) of the elements in v, 111 # and T.mean(LP[T.arange(y.shape[0]),y]) is the mean (across minibatch examples) of the elements in v,
112 # i.e., the mean log-likelihood across the minibatch. 112 # i.e., the mean log-likelihood across the minibatch.
113 return -T.mean( T.log( self.p_y_given_x )[ T.arange( y.shape[0] ), y ] ) 113 return -T.mean( T.log( self.p_y_given_x )[ T.arange( y.shape[0] ), y ] )
114 114
115 def MSE(self, y):
116 return -T.mean(abs((self.p_t_given_x)[T.arange(y.shape[0]), y]-y)**2)
115 117
116 def errors( self, y ): 118 def errors( self, y ):
117 """Return a float representing the number of errors in the minibatch 119 """Return a float representing the number of errors in the minibatch
118 over the total number of examples of the minibatch ; zero one 120 over the total number of examples of the minibatch ; zero one
119 loss over the size of the minibatch 121 loss over the size of the minibatch