kk7nc/RMDL

ValueError

Closed this issue · 18 comments

First of all thank you so much for your efforts in this paper, it is very interesting. But when I tried to run the code for text classification I got this error ("ValueError: max_features=[20, 500, 50], neither a positive integer nor None"). This error occurs when I run [RMDL.Text_Classification(X_train, y_train, X_test, y_test, batch_size, sparse_categorical, Random_Deep, n_epochs]. So can you please help me to overcome that.

Regards,
Saja

kk7nc commented

Thank you for your question
you can try:

RMDL.Text_Classification(X_train, y_train, X_test, y_test,
                         batch_size=batch_size,
                         sparse_categorical=0,
                         random_deep=Random_Deep,
                         epochs=n_epochs)

Thank you for your answer, after modifying the code as you mentioned a list of errors appeared to me similar to the asked in (kk7nc/HDLTex#5)
{Error in model 0 try to re-generate another model
DNN 0
<keras.optimizers.RMSprop object at 0x0000024BB96999E8>
Error in model 0 try to re-generate another model
DNN 0
<keras.optimizers.Adam object at 0x0000024BB93965F8>
Error in model 0 try to re-generate another model
DNN 0
<keras.optimizers.Adagrad object at 0x0000024C20F14F98>
Error in model 0 try to re-generate another model
DNN 0 }

I read your answer, so have you any advice for me to overcome this error.

Thanks again.

kk7nc commented

Thank you for your email, this is not an error, sometimes your memory and hardware of your computer does not capacity to run a model so it tries to reduce it, can you check with only RNN and CNN?

please inform us about your hardware,

Random_Deep = [0,0,3]

RMDL.Text_Classification(X_train, y_train, X_test, y_test,
                         batch_size=batch_size,
                         sparse_categorical=0,
                         random_deep=Random_Deep,
                         epochs=n_epochs)

I am having the some problem with 32 Gb of RAM and a 1070 Graphic Memory. Any suggestions?
Thank you.

kk7nc commented

can you try by the following option:

Random_Deep = [0,0,3]
batch_size = 20
RMDL.Text_Classification(X_train, y_train, X_test, y_test,
                         batch_size=batch_size,
                         sparse_categorical=0,
                         random_deep=Random_Deep,
                         epochs=n_epochs)

Hello I also have this problem running on Google Colab: I even decreased it to only 1 CNN and batch_size 4

Random_Deep = [0,0,1]
batch_size = 4 # 16 also got prob
n_epochs = 1
Text_Classification(X_train, y_train, X_test, y_test,
batch_size=batch_size,
sparse_categorical=0,
random_deep=Random_Deep,
epochs=n_epochs)

I also faced the same problem when using Tesla P100 on Azure

This is the error I get:

Error in model 0 try to re-generate an other model
CNN 0
Filter 6
Node 350
<keras.optimizers.Adam object at 0x7fc45c06c7b8>
Error in model 0 try to re-generate an other model
CNN 0
Filter 6
Node 400
<keras.optimizers.RMSprop object at 0x7fc41875ef60>
Error in model 0 try to re-generate an other model
CNN 0
Filter 6
Node 183
<keras.optimizers.RMSprop object at 0x7fc41832b630>
Error in model 0 try to re-generate an other model
CNN 0
Filter 5
Node 377
<keras.optimizers.Adagrad object at 0x7fc401eda550>

So I think it is failing at the optimizer?

kk7nc commented

Thank you,
Can you explain, did you download GloVe? and can you verify that glove is in there?
the second the code is working for our examples such as Reuters21578 (https://github.com/kk7nc/RMDL/blob/master/Examples/Reuters21578.py)

I also have this problem
Error in model 0 try to re-generate an other model
How to deal with it? I change to a small dataset, no effect

Hi,

Thank you for your methods and code.

I am also getting this error:

<keras.optimizers.Adagrad object at 0x7f374c4c0fd0> Error in model 0 try to re-generate another model

I am simply running your example (on IMBD data) on a server with 128GB memory. So I guess the memory should not be the issue?

Haven't changed anything in the code from your example but pointed to my GloVe folder.

What could be the reason?

kk7nc commented

Hi,

Thank you for your methods and code.

I am also getting this error:

<keras.optimizers.Adagrad object at 0x7f374c4c0fd0> Error in model 0 try to re-generate another model

I am simply running your example (on IMBD data) on a server with 128GB memory. So I guess the memory should not be the issue?

Haven't changed anything in the code from your example but pointed to my GloVe folder.

What could be the reason?

Can you test only on DNN the only CNN?
Random_Deep = [0,0,3]
batch_size = 20

RMDL.Text_Classification(X_train, y_train, X_test, y_test,
                         batch_size=batch_size,
                         sparse_categorical=0,
                         random_deep=Random_Deep,
                         epochs=n_epochs)

Thanks,
when I test, will let you know.

Hi, also the same problem in Colab and in my local machine in 16 GB RAM and 8GB GTX1070
I am trying the MNIST classification example.
Event with this config

Random_Deep = [0,0,3]
batch_size = 20
RMDL.Text_Classification(X_train, y_train, X_test, y_test,
batch_size=batch_size,
sparse_categorical=0,
random_deep=Random_Deep,
epochs=n_epochs)

(28, 28, 1)
<keras.optimizers.Adam object at 0x7f39b67fb780>
Error in model 0 try to re-generate an other model
DNN 0

(28, 28, 1)
<keras.optimizers.Adagrad object at 0x7f39b67c7358>
Error in model 0 try to re-generate an other model
DNN 0

ben74 commented

Same problem here .. :(
Anyways, that's not related to tensorflow v1/v2 usage, neither the random_deep [0,0,3] or lowering any of the numbers below seem to work

<keras.optimizers.Adagrad object at 0x7f36106ccd30>
Error in model 0 try to re-generate an other model
CNN 0
Filter 7
Node 449

ISSUE:
"Error in model 0 try to re-generate another model"

FIX:
ModelCheckpoint(filepath,
monitor="val_acc" >>>>>>> monitor="val_accuracy"

I didn't see a definitive solution to this here, so I am posting my solution which worked for me:

Found this on GitHub...
"In Google Colab it works with "val_acc", but in Kaggle with "val_accuracy". Keras related. I believe.

This quote is referring to, in this case, values set in files "RMDL_Image" and "RMDL_Text" for "ModelCheckpoint".

Change the 3 instances in each file from >> to:

monitor="val_acc" >>>> monitor="val_accuracy"

Answer from @gegilligan works well:

Change the 3 instances in each file from >> to:

monitor="val_acc" >>>> monitor="val_accuracy"

Environment:

  • Windows 10 x64
  • nVidia RTX 2080 Ti

Complete setup:

# Run as Anaconda Admin prompt
conda create -n RMDL
conda activate RMDL
conda install -c anaconda tensorflow-gpu
# After "git clone" of RMDL.
conda install --file requirements.txt
# First replace all 'val_acc' with 'val_accuracy' to be compatible with new version of Keras.
python setup.py install
# Install Jupyter Lab
conda install -c conda-forge jupyterlab
jupyter lab

Then copy Examples\MNIST.py to a Jupyter notebook and run.

Try this for a quick test:

n_epochs = [5, 5, 5]  # DNN--RNN-CNN
Random_Deep = [1, 1, 1]  # DNN--RNN-CNN

This error still appears before generating the CNN, but it can be ignored:

Error in model 0  try to re-generate another model
CNN  0 

Looking through the code, it is trying different convolutional network configurations until it finds one that works. Try changing the shape of the image from 28x28 to something else, and it will try more configurations before settling on one that fits. If shape is too awkward (i.e. 112x7) then it will fail altogether, and only the DNN and RNN will work.

Hi, I'm still having the same issue with the following message:

Error in model 0 try to re-generate another model CNN 0

Even with the current fix of setting monitor="val_acc" to monitor="val_accuracy". I'm running the MNIST_example.py on Google Colab notebook, on the 2020 MacBook Air with M1 chip, 8GB memory and 256GB storage.