tf-lm
tf-lm copied to clipboard
error 'lm' object has no attribute 'use_cache'
Hi, I am trying to run the code on google colab.
!python main.py --config ../config/en-ptb_char_discourse.config
I get this error :
TensorFlow version: 1.14.0
WARNING: Logging before flag parsing goes to stderr.
W0806 10:33:55.194962 140392852367232 deprecation_wrapper.py:119] From main.py:501: The name tf.app.run is deprecated. Please use tf.compat.v1.app.run instead.
configuration:
trainer trainer
vocab_size 10000
layer LSTM
data_path ../
char True
num_layers 1
size 512
max_epoch 6
num_steps 35
log_dir logs/
save_path models/ptb/ptb_char_discoure/
lr_decay 0.8
init_scale 0.05
optimizer sgd
learning_rate 1
batch_size 20
forget_bias 0
max_grad_norm 5
dropout 0.5
vocab False
max_max_epoch 39
softmax full
Character-level data
W0806 10:33:55.613151 140392852367232 deprecation_wrapper.py:119] From /content/drive/My Drive/Colab Notebooks/tf-lm-master 2/scripts/lm_data.py:417: The name tf.gfile.GFile is deprecated. Please use tf.io.gfile.GFile instead.
W0806 10:34:02.899137 140392852367232 deprecation_wrapper.py:119] From main.py:355: The name tf.set_random_seed is deprecated. Please use tf.compat.v1.set_random_seed instead.
Create training model...
W0806 10:34:02.929327 140392852367232 deprecation_wrapper.py:119] From main.py:364: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.
Standard LM
W0806 10:34:02.930150 140392852367232 deprecation_wrapper.py:119] From /content/drive/My Drive/Colab Notebooks/tf-lm-master 2/scripts/lm.py:56: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.
W0806 10:34:05.335197 140392852367232 lazy_loader.py:50]
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
* https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
* https://github.com/tensorflow/addons
* https://github.com/tensorflow/io (for I/O related ops)
If you depend on functionality not listed there, please file an issue.
W0806 10:34:05.335514 140392852367232 deprecation.py:323] From /content/drive/My Drive/Colab Notebooks/tf-lm-master 2/scripts/lm.py:80: __init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.
Instructions for updating:
This class is equivalent as tf.keras.layers.LSTMCell, and will be replaced by that in Tensorflow 2.0.
W0806 10:34:05.335957 140392852367232 deprecation.py:323] From /content/drive/My Drive/Colab Notebooks/tf-lm-master 2/scripts/lm.py:81: __init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.
Instructions for updating:
This class is equivalent as tf.keras.layers.StackedRNNCells, and will be replaced by that in Tensorflow 2.0.
W0806 10:34:05.387567 140392852367232 deprecation_wrapper.py:119] From /content/drive/My Drive/Colab Notebooks/tf-lm-master 2/scripts/lm.py:114: The name tf.get_variable is deprecated. Please use tf.compat.v1.get_variable instead.
W0806 10:34:05.413235 140392852367232 deprecation.py:506] From /content/drive/My Drive/Colab Notebooks/tf-lm-master 2/scripts/lm.py:148: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.
Instructions for updating:
Please use `rate` instead of `keep_prob`. Rate should be set to `rate = 1 - keep_prob`.
W0806 10:34:05.421999 140392852367232 deprecation.py:323] From /content/drive/My Drive/Colab Notebooks/tf-lm-master 2/scripts/lm.py:197: dynamic_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version.
Instructions for updating:
Please use `keras.layers.RNN(cell)`, which is equivalent to this API
W0806 10:34:05.806507 140392852367232 deprecation.py:506] From /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/rnn_cell_impl.py:738: calling __init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
Instructions for updating:
Call initializer instance with the dtype argument instead of passing it to the constructor
W0806 10:34:06.290380 140392852367232 deprecation_wrapper.py:119] From /content/drive/My Drive/Colab Notebooks/tf-lm-master 2/scripts/lm.py:243: The name tf.trainable_variables is deprecated. Please use tf.compat.v1.trainable_variables instead.
W0806 10:34:06.506848 140392852367232 deprecation.py:323] From /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/clip_ops.py:286: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.where in 2.0, which has the same broadcast rule as np.where
W0806 10:34:06.513619 140392852367232 deprecation_wrapper.py:119] From /content/drive/My Drive/Colab Notebooks/tf-lm-master 2/scripts/lm.py:338: The name tf.train.GradientDescentOptimizer is deprecated. Please use tf.compat.v1.train.GradientDescentOptimizer instead.
W0806 10:34:06.513880 140392852367232 deprecation_wrapper.py:119] From /content/drive/My Drive/Colab Notebooks/tf-lm-master 2/scripts/lm.py:258: The name tf.train.get_global_step is deprecated. Please use tf.compat.v1.train.get_global_step instead.
W0806 10:34:06.527863 140392852367232 deprecation_wrapper.py:119] From main.py:367: The name tf.summary.merge_all is deprecated. Please use tf.compat.v1.summary.merge_all instead.
W0806 10:34:06.528095 140392852367232 deprecation_wrapper.py:119] From main.py:368: The name tf.summary.FileWriter is deprecated. Please use tf.compat.v1.summary.FileWriter instead.
W0806 10:34:06.531001 140392852367232 deprecation_wrapper.py:119] From main.py:370: The name tf.train.Saver is deprecated. Please use tf.compat.v1.train.Saver instead.
Create validation model...
Standard LM
Create testing model...
Standard LM
W0806 10:34:06.752048 140392852367232 deprecation.py:323] From main.py:392: __init__ (from tensorflow.python.training.supervisor) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.MonitoredTrainingSession
2019-08-06 10:34:07.041900: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2200000000 Hz
2019-08-06 10:34:07.042184: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x56003971a000 executing computations on platform Host. Devices:
2019-08-06 10:34:07.042239: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): <undefined>, <undefined>
2019-08-06 10:34:07.237528: W tensorflow/compiler/jit/mark_for_compilation_pass.cc:1412] (One-time warning): Not using XLA:CPU for cluster because envvar TF_XLA_FLAGS=--tf_xla_cpu_global_jit was not set. If you want XLA:CPU, either set that envvar, or use experimental_jit_scope to enable XLA:CPU. To confirm that XLA is active, pass --vmodule=xla_compilation_cache=1 (as a proper command-line flag, not via TF_XLA_FLAGS) or set the envvar XLA_FLAGS=--xla_hlo_profile.
I0806 10:34:07.280142 140392852367232 session_manager.py:500] Running local_init_op.
I0806 10:34:07.287978 140392852367232 session_manager.py:502] Done running local_init_op.
I0806 10:34:07.655586 140392852367232 supervisor.py:737] Starting standard services.
I0806 10:34:07.661370 140392852367232 supervisor.py:743] Starting queue runners.
I0806 10:34:07.661602 140391873472256 supervisor.py:1117] Saving checkpoint to path models/ptb/ptb_char_discoure/model.ckpt
Learning rate: 1.0
Start training epoch...
I0806 10:34:07.844892 140392852367232 coordinator.py:224] Error reported to Coordinator: <type 'exceptions.AttributeError'>, 'lm' object has no attribute 'use_cache'
Traceback (most recent call last):
File "main.py", line 501, in <module>
tf.app.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/usr/local/lib/python2.7/dist-packages/absl/app.py", line 300, in run
_run_main(main, args)
File "/usr/local/lib/python2.7/dist-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "main.py", line 406, in main
train_obj.train()
File "/content/drive/My Drive/Colab Notebooks/tf-lm-master 2/scripts/trainer.py", line 43, in train
train_perplexity = self.train_runner()
File "/content/drive/My Drive/Colab Notebooks/tf-lm-master 2/scripts/run_epoch.py", line 39, in __call__
fetches = self.create_fetches()
File "/content/drive/My Drive/Colab Notebooks/tf-lm-master 2/scripts/run_epoch.py", line 192, in create_fetches
if self.model.use_cache:
AttributeError: 'lm' object has no attribute 'use_cache'
Does anyone know how to solve it?
I fixed an error in the code: there was some confusion between self.cache and self.use_cache. Can you try again with the new code and let me know if it works now?
No, the problem still exists.
TensorFlow version: 1.14.0 WARNING: Logging before flag parsing goes to stderr. W0808 14:35:07.711864 140663639402368 deprecation_wrapper.py:119] From main.py:501: The name tf.app.run is deprecated. Please use tf.compat.v1.app.run instead.
configuration: trainer trainer vocab_size 10000 layer LSTM data_path ../ char True num_layers 1 size 512 max_epoch 6 num_steps 35 log_dir logs/ save_path models/ptb/ptb_char_discoure/ lr_decay 0.8 init_scale 0.05 optimizer sgd learning_rate 1 batch_size 20 forget_bias 0 max_grad_norm 5 dropout 0.5 vocab False max_max_epoch 39 softmax full Character-level data W0808 14:35:08.116250 140663639402368 deprecation_wrapper.py:119] From /content/drive/My Drive/Colab Notebooks/tf-lm-master/scripts/lm_data.py:417: The name tf.gfile.GFile is deprecated. Please use tf.io.gfile.GFile instead.
W0808 14:35:16.174273 140663639402368 deprecation_wrapper.py:119] From main.py:355: The name tf.set_random_seed is deprecated. Please use tf.compat.v1.set_random_seed instead.
Create training model... W0808 14:35:16.175270 140663639402368 deprecation_wrapper.py:119] From main.py:364: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.
Standard LM W0808 14:35:16.175949 140663639402368 deprecation_wrapper.py:119] From /content/drive/My Drive/Colab Notebooks/tf-lm-master/scripts/lm.py:56: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.
W0808 14:35:18.628976 140663639402368 lazy_loader.py:50] The TensorFlow contrib module will not be included in TensorFlow 2.0. For more information, please see:
- https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
- https://github.com/tensorflow/addons
- https://github.com/tensorflow/io (for I/O related ops) If you depend on functionality not listed there, please file an issue.
W0808 14:35:18.629364 140663639402368 deprecation.py:323] From /content/drive/My Drive/Colab Notebooks/tf-lm-master/scripts/lm.py:80: init (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version. Instructions for updating: This class is equivalent as tf.keras.layers.LSTMCell, and will be replaced by that in Tensorflow 2.0. W0808 14:35:18.629961 140663639402368 deprecation.py:323] From /content/drive/My Drive/Colab Notebooks/tf-lm-master/scripts/lm.py:81: init (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version. Instructions for updating: This class is equivalent as tf.keras.layers.StackedRNNCells, and will be replaced by that in Tensorflow 2.0. W0808 14:35:18.686391 140663639402368 deprecation_wrapper.py:119] From /content/drive/My Drive/Colab Notebooks/tf-lm-master/scripts/lm.py:114: The name tf.get_variable is deprecated. Please use tf.compat.v1.get_variable instead.
W0808 14:35:18.712331 140663639402368 deprecation.py:506] From /content/drive/My Drive/Colab Notebooks/tf-lm-master/scripts/lm.py:148: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.
Instructions for updating:
Please use rate
instead of keep_prob
. Rate should be set to rate = 1 - keep_prob
.
W0808 14:35:18.721059 140663639402368 deprecation.py:323] From /content/drive/My Drive/Colab Notebooks/tf-lm-master/scripts/lm.py:197: dynamic_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version.
Instructions for updating:
Please use keras.layers.RNN(cell)
, which is equivalent to this API
W0808 14:35:19.125068 140663639402368 deprecation.py:506] From /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/rnn_cell_impl.py:738: calling init (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
Instructions for updating:
Call initializer instance with the dtype argument instead of passing it to the constructor
W0808 14:35:19.621726 140663639402368 deprecation_wrapper.py:119] From /content/drive/My Drive/Colab Notebooks/tf-lm-master/scripts/lm.py:243: The name tf.trainable_variables is deprecated. Please use tf.compat.v1.trainable_variables instead.
W0808 14:35:19.843894 140663639402368 deprecation.py:323] From /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/clip_ops.py:286: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version. Instructions for updating: Use tf.where in 2.0, which has the same broadcast rule as np.where W0808 14:35:19.850924 140663639402368 deprecation_wrapper.py:119] From /content/drive/My Drive/Colab Notebooks/tf-lm-master/scripts/lm.py:338: The name tf.train.GradientDescentOptimizer is deprecated. Please use tf.compat.v1.train.GradientDescentOptimizer instead.
W0808 14:35:19.851279 140663639402368 deprecation_wrapper.py:119] From /content/drive/My Drive/Colab Notebooks/tf-lm-master/scripts/lm.py:258: The name tf.train.get_global_step is deprecated. Please use tf.compat.v1.train.get_global_step instead.
W0808 14:35:19.861686 140663639402368 deprecation_wrapper.py:119] From main.py:367: The name tf.summary.merge_all is deprecated. Please use tf.compat.v1.summary.merge_all instead.
W0808 14:35:19.862009 140663639402368 deprecation_wrapper.py:119] From main.py:368: The name tf.summary.FileWriter is deprecated. Please use tf.compat.v1.summary.FileWriter instead.
W0808 14:35:20.028028 140663639402368 deprecation_wrapper.py:119] From main.py:370: The name tf.train.Saver is deprecated. Please use tf.compat.v1.train.Saver instead.
Create validation model...
Standard LM
Create testing model...
Standard LM
W0808 14:35:20.262886 140663639402368 deprecation.py:323] From main.py:392: init (from tensorflow.python.training.supervisor) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.MonitoredTrainingSession
2019-08-08 14:35:20.574570: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2200000000 Hz
2019-08-08 14:35:20.574818: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55725e246000 executing computations on platform Host. Devices:
2019-08-08 14:35:20.574850: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0):
Ok, the issue was not run_epoch.py but in lm.py. I added use_cache to the class `lm'. Can you check whether it works now?