IndicoDataSolutions / Passage

A little library for text analysis with RNNs.
MIT License
530 stars 134 forks source link

Problem with Multiclass Classification #35

Closed naeemulhassan closed 9 years ago

naeemulhassan commented 9 years ago

My data has three classes and I used cce as cost function. Here is the code for layers and model.

layers = [
    Embedding(size=256, n_features=tokenizer.n_features),
    GatedRecurrent(size=512, seq_output=False, p_drop=0.75), #LstmRecurrent(size=512, seq_output=False, p_drop=0.75)
    Dense(size = 1, activation='sigmoid')
    ]
model = RNN(layers=layers, cost='cce', updater = Adadelta(lr=0.5))

This is the error I receive. Any idea?

/usr/local/lib/python2.7/dist-packages/theano/scan_module/scan_perform_ext.py:133: RuntimeWarning: numpy.ndarray size changed, may indicate binary incompatibility from scan_perform.scan_perform import Traceback (most recent call last): File "myRNN.py", line 44, in model.fit(train_tokens, train_labels, n_epochs = 9) File "/home/naeemul/passage/passage/models.py", line 82, in fit c = self._train(xmb, ymb) File "/usr/local/lib/python2.7/dist-packages/theano/compile/function_module.py", line 606, in call storage_map=self.fn.storage_map) File "/usr/local/lib/python2.7/dist-packages/theano/compile/function_module.py", line 595, in call outputs = self.fn() ValueError: Input dimension mis-match. (input[0].shape[1] = 2, input[1].shape[1] = 1) Apply node that caused the error: Elemwise{Composite{(i0 \ scalar_softplus((-i1)))}}(<TensorType(float64, matrix)>, Elemwise{Add}[(0, 0)].0) Inputs types: [TensorType(float64, matrix), TensorType(float64, matrix)] Inputs shapes: [(64, 2), (64, 1)] Inputs strides: [(16, 8), (8, 8)] Inputs values: ['not shown', 'not shown']

HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag 'optimizer=fast_compile'. If that does not work, Theano optimizations can be disabled with 'optimizer=None'. HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.

Thanks!

EDIT: Found the problem. I set the Dense size wrong. Closing the issue.