As part of a personal project I'm trying to modify the example code given in Theano documentation (Multilayer Perceptron) with my own data.
Till now I managed to bring my own (text) data in the format required and I want to build a binary classifier. The thing is that when I write that the number of outputs is 1 i.e.
classifier = MLP(rng=rng, input=x, n_in=49, n_hidden=n_hidden, n_out=1)
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Asterios\Anaconda\lib\site-packages\spyderlib\widgets\externalshell \sitecustomize.py", line 540, in runfile
execfile(filename, namespace)
File "C:/Users/Asterios/Documents/Python/TripAdvisor/untitled4.py", line 603, in <module>
params = test_mlp()
File "C:/Users/Asterios/Documents/Python/TripAdvisor/untitled4.py", line 553, in test_mlp
minibatch_avg_cost = train_model(minibatch_index)
File "C:\Users\Asterios\Anaconda\lib\site-packages\theano-0.6.0-py2.7.egg\theano\compile\function_module.py", line 588, in __call__
self.fn.thunks[self.fn.position_of_error])
File "C:\Users\Asterios\Anaconda\lib\site-packages\theano-0.6.0-py2.7.egg\theano\compile\function_module.py", line 579, in __call__
outputs = self.fn()
ValueError: y_i value out of bounds
Apply node that caused the error: CrossentropySoftmaxArgmax1HotWithBias(Dot22.0, b, Elemwise{Cast{int32}}.0)
Inputs shapes: [(10L, 1L), (1L,), (10L,)]
Inputs strides: [(8L, 8L), (8L,), (4L,)]
Inputs types: [TensorType(float64, matrix), TensorType(float64, vector), TensorType(int32, vector)]
Use the Theano flag 'exception_verbosity=high' for a debugprint of this apply node.
The output of my training data (before casting to theano shared type) is like this:
array([1, 1, 1, ..., 0, 0, 0], dtype=int64)
The strange thing is that if I use as a number of output neurons ANYTHING above 1 (e.g. n_out=2), the code is running without any errors but of course now there are many output neurons that have no practical meaning.
Could some please explain why the code with binary output seems to give me an error? How can I get this working?
Thank you!