Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when retraining word vector #23

Closed
wailoktam opened this issue Jun 6, 2017 · 3 comments
Closed

error when retraining word vector #23

wailoktam opened this issue Jun 6, 2017 · 3 comments

Comments

@wailoktam
Copy link

Hi, I have reverted to an earlier commit: https://github.com/alexander-rakhlin/CNN-for-Sentence-Classification-in-Keras/tree/0a10445fbd0a1c783e6231cd1accb1e1a4e2252f

The codes run fine with the provided embeddings. But when I delete the embeddings in the models directory and retrain it. I get the following errors:

trainGraph.py:127: UserWarning: Update your Conv1D call to the Keras 2 API: Conv1D(activation="relu", padding="valid", strides=1, filters=3, kernel_size=3)
subsample_length=1)(graph_in)
trainGraph.py:128: UserWarning: Update your MaxPooling1D call to the Keras 2 API: MaxPooling1D(pool_size=2)
pool = MaxPooling1D(pool_length=2)(conv)
trainGraph.py:127: UserWarning: Update your Conv1D call to the Keras 2 API: Conv1D(activation="relu", padding="valid", strides=1, filters=3, kernel_size=4)
subsample_length=1)(graph_in)
trainGraph.py:133: UserWarning: The Merge layer is deprecated and will be removed after 08/2017. Use instead layers from keras.layers.merge, e.g. add, concatenate, etc.
out = Merge(mode='concat')(convs)
trainGraph.py:137: UserWarning: Update your Model call to the Keras 2 API: Model(outputs=Join.0, inputs=/input_1)
graph = Model(input=graph_in, output=out)
/root/anaconda/lib/python2.7/site-packages/keras/models.py:849: UserWarning: The nb_epoch argument in fit has been renamed epochs.
warnings.warn('The nb_epoch argument in fit '
Traceback (most recent call last):
File "trainGraph.py", line 158, in
model.fit(x_shuffled, y_shuffled, batch_size=batch_size, nb_epoch=num_epochs, validation_split=val_split, verbose=2)
File "/root/anaconda/lib/python2.7/site-packages/keras/models.py", line 868, in fit
initial_epoch=initial_epoch)
File "/root/anaconda/lib/python2.7/site-packages/keras/engine/training.py", line 1434, in fit
batch_size=batch_size)
File "/root/anaconda/lib/python2.7/site-packages/keras/engine/training.py", line 1310, in _standardize_user_data
exception_prefix='input')
File "/root/anaconda/lib/python2.7/site-packages/keras/engine/training.py", line 139, in _standardize_input_data
str(array.shape))
ValueError: Error when checking input: expected embedding_1_input to have shape (None, 56) but got array with shape (481625, 629)

Any idea to fix it? Thanks.

@alexander-rakhlin
Copy link
Owner

Hi,

I am short of time these days. Current recommendation is to update old code for recent Keras and verify array dimensionality it produces to match the provided embeddings. The error here:

ValueError: Error when checking input: expected embedding_1_input to have shape (None, 56) but got array with shape (481625, 629)

@wailoktam
Copy link
Author

Hi, I have rewritten the code for keras 2 but I am stuck at this line:

conv = Conv1D(filters=num_filters, kernerl_size=fsz, padding='valid', activation='relu', strides=1)(graph_in)

I am getting this error: File "trainGraph.py", line 131, in
conv = Conv1D(filters=num_filters, kernerl_size=fsz, padding='valid', activation='relu', strides=1)(graph_in)
TypeError: init() takes at least 3 arguments (2 given)

Any idea? Thanks in advance

@alexander-rakhlin
Copy link
Owner

Please see updated version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants