Search code examples
pythontheanosoftmax

getting error with softmax and cross entropy in theano


I'm implementing a DNN with Theano. At the last layer of DNN, I'm using a softmax as a nonlinear function from theano.tensor.nnet.softmax

As a lost function i'm using cross entropy from T.nnet.binary_crossentropy But I get a strange error: "The following error happened while compiling the node', GpuDnnSoftmaxGrad{tensor_format='bc01' ..."

I'm a newbie with theano and can't figure out what's wrong with this model. Your help is appreciated PS: my guess is it is somehow related to the fact that softmax takes a 2D tensor and returns a 2D tensor.

PS2:I'm using the bleeding edge Theano (just cloned) my CUDA version is old it is 4.2 BUT I'm almost sure that that's not the problem since I'm working without error with other DNN tools written based on Theano. I'm using pylearn2 to accelerate and that's not the problem either since I already used it successfully with the current Theano and CUDA in another DNN.

The error happens at this line: train= theano.function([idx], train_loss, givens=givens, updates=updates)

The full error message is: cmodule.py", line 293, in dlimport rval = __import__(module_name, {}, {}, [module_name]) RuntimeError: ('The following error happened while compiling the node', GpuDnnSoftmaxGrad{tensor_format='bc01', mode='channel', algo='accurate'}(GpuContiguous.0, GpuContiguous.0), '\n', 'could not create cuDNN handle: The handle was not initialized(Is your driver recent enought?).', "[GpuDnnSoftmaxGrad{tensor_format='bc01', mode='channel', algo='accurate'}(<CudaNdarrayType(float32, (False, False, True, True))>, <CudaNdarrayType(float32, (False, False, True, True))>)]")

The Cross entropy funcion I'm using is defined as: error = T.mean(T.nnet.binary_crossentropy(input, target_y) where input is the output of the softmax layer and target_y is the labels.


Solution

  • solved. I had to use T.nnet.categorical_crossentropy since my target variable is an integer vector.