Hi, I have downloaded an open source code which uses theano (https://www.repository.cam.ac.uk/handle/1810/263961)
When I try running the learning step I get an error (I have set theano verbosity to high). python train_bnn.py -i lytroPatches_30x30.pkl.gz Traceback (most recent call last): File "train_bnn.py", line 525, in <module> evaluate_dcnn(dataset=dataset_file, nkerns=kernels) File "train_bnn.py", line 440, in evaluate_dcnn print("res = {}".format(validate_model(0))) File "/home/PRODUITS/COTS/python2.7.9/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/compile/function_module.py" , line 579, in __call__ outputs = self.fn() File "/home/PRODUITS/COTS/python2.7.9/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/compile/debugmode.py" , line 2030, in deco return f() File "/home/PRODUITS/COTS/python2.7.9/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/compile/debugmode.py" , line 1790, in f thunk_py() File "/home/PRODUITS/COTS/python2.7.9/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/compile/debugmode.py" , line 1623, in <lambda> n=node: p(n, [x[0] for x in i], o)) File "/home/PRODUITS/COTS/python2.7.9/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/tensor/basic.py" , line 1418, in perform max[0] = theano._asarray(numpy.max(x, axis), File "/home/PRODUITS/COTS/python2.7.9/lib/python2.7/site-packages/numpy/core/fromnumeric.py" , line 2320, in amax out=out, **kwargs) File "/home/PRODUITS/COTS/python2.7.9/lib/python2.7/site-packages/numpy/core/_methods.py" , line 26, in _amax return umr_maximum(a, axis, None, out, keepdims) TypeError: only integer scalar arrays can be converted to a scalar index Apply node that caused the error: MaxAndArgmax(Softmax.0, TensorConstant{(1 ,) of 1}) Inputs shapes: [(100, 2), (1,)] Inputs strides: [(16, 8), (8,)] Inputs types: [TensorType(float64, matrix), TensorType(int64, (True,))] Debugprint of the apply node: MaxAndArgmax.0 [@A] <TensorType(float64, vector)> 'max' MaxAndArgmax.1 [@A] <TensorType(int64, vector)> 'argmax' Now I am really new to Theano and do not even have dnn experience which makes it hard to understand the messages I get from Theano and to debug this code... As far as I know this could even be not related to Theano (though I hope I am not wasting your time). What I think I have understood is that the train_model theano.function goes well. But the validate_model and test_model theano.function do not. I think this is due to the errors() method of the LogisticRegression layer (the negative_log_likelihood is used what I guess is called the cost function for the train_model, while the errors one is the function that is supposed to test how well the dnn has learnt so far). class LogisticRegression(object): ''' Logistic regression layer ''' # initialization def __init__(self, input, n_in, n_out): # initialize the weight matrix to zeros self.W = theano.shared(value=np.zeros((n_in, n_out), dtype=theano.config.floatX), name='W', borrow=True) # initialize the bias term self.b = theano.shared(value=np.zeros((n_out,), dtype=theano.config.floatX), name='b', borrow=True) # define symbolic expressions for probability and prediction self.p_y_given_x = T.nnet.softmax(T.dot(input, self.W) + self.b) self.y_pred = T.argmax(self.p_y_given_x, axis=1) self.params = [self.W, self.b] def negative_log_likelihood(self, y): # the loss function return -T.mean(T.log(self.p_y_given_x)[T.arange(y.shape[0]), y]) def errors(self, y): # check if y has same dimension of y_pred if y.ndim != self.y_pred.ndim: raise TypeError( 'y should have the same shape as self.y_pred', ('y', y.type, 'y_pred', self.y_pred.type) ) # check if y is of the current data type if y.dtype.startswith('int'): # compute error return T.mean(T.neq(self.y_pred, y)) else: print("NotImplementedError for LogisticRegression::errors()") raise NotImplementedError() So here I come to you hopping that maybe you will have hints or clues to help me find out where this error comes from. Could it be related to the shapes of the tensors ? How can I access them ? I have truble playing with tensors so far... I really thank you for the time you will spend reading this and answering it. -- --- You received this message because you are subscribed to the Google Groups "theano-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.