1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Recurrent Neural Networks for Drawing Classification tutorial code doesn't run on...

Discussão em 'Python' iniciado por Stack, Dezembro 1, 2025.

  1. Stack

    Stack Membro Participativo

    I'm a beginner in deep leaerning and Tensorflow.

    I tried to run the tutorial code for Recurrent Neural Networks for Drawing Classification on my computer following the directions written there. But the provided tutorial code file didn't run on Tensorflow 2.8.0, apparently due to Tensorflow version difference. I upgraded the code using tf_upgrade_v2 to make it compatible with Tensorflow 2. But the updated code still had 'tf.contrib' codes, which are not compatible with Tensorflow 2 and have to be mannualy updated. I have no idea how to do it.

    I would appreciate if I could get some advice here on how to update 'tf.contrib' parts of the tutorial code manually to run it on Tensorflow 2.

    Here's the details of what I did. (System: Windows 10 Pro 64-bit, python 3.8.12, Jupyter Lab 3.2.1)


    1. I installed Tensorflow 2.8.0 in Anaconda.


    2. I downloaded the tutorial code train_model.py from Recurrent Neural Networks for Drawing Classification


    3. I downloaded the data file from here and unzipped it.


    4. In Jupyter Lab, I ran the following code

    %run -i train_model.py --model_dir=model_dir\
    --training_data=rnn_tutorial_data/training.tfrecord-?????-of-????? \
    --eval_data=rnn_tutorial_data/eval.tfrecord-?????-of-????? \
    --classes_file=rnn_tutorial_data/training.tfrecord.classes


    I added --model_dir=model_dirbecause the first run produced an error saying "ValueError: model_dir should be non-empty."

    I ran the code above and got an error saying "AttributeError: module 'tensorflow' has no attribute 'app'".

    1. I learned through search that 'app' is no longer used in Tensorflow 2. So I upgraded the train_model.py using tf_upgrade_v2 program as shown in the Tensorflow Core page.

    The output report of tf_upgrade_v2 gave numerous warnings and errors like following:

    175:13: WARNING: Using member tf.contrib.rnn.LSTMBlockCell in deprecated module tf.contrib.rnn. (Manual edit required) tf.contrib.rnn.* has been deprecated, and widely used cells/functions will be moved to tensorflow/addons repository. Please check it there and file Github issues if necessary.
    175:13: ERROR: Using member tf.contrib.rnn.LSTMBlockCell in deprecated module tf.contrib. tf.contrib.rnn.LSTMBlockCell cannot be converted automatically. tf.contrib will not be distributed with TensorFlow 2.0, please consider an alternative in non-contrib TensorFlow, a community-maintained repository such as tensorflow/addons, or fork the required code.


    1. But anyway, I ran the updated code in Jupyter Lab. Not surprisingly, I got the error, "AttributeError: module 'tensorflow' has no attribute 'contrib'".


    2. I searched for information on tensorflow/addons, but couldn't find one that tells me how they can substitute the 'contrib' codes.

    Continue reading...

Compartilhe esta Página