models icon indicating copy to clipboard operation
models copied to clipboard

TypeError: unsupported operand type(s) for *: 'NoneType' and 'int' in keras_utils.py

Open tkngoutham opened this issue 7 years ago • 4 comments

trying to run trasformer in v2 with TF-2.0 stable and branch in models : tf_2_0_rc1(https://github.com/tensorflow/models/tree/tf_2_0_rc1) as per ticket https://github.com/tensorflow/models/issues/7644 with below command: python transformer_main.py --data_dir=$DATA_DIR --model_dir=$MODEL_DIR --vocab_file=$VOCAB_FILE --param_set=base --bleu_source=$DATA_DIR/newstest2014.en --bleu_ref=$DATA_DIR/newstest2014.de

Got error with below Stack trace:

Total params: 61,362,176 Trainable params: 61,362,176 Non-trainable params: 0


I1118 07:25:13.213394 139963829905152 transformer_main.py:298] Start train iteration at global step:0 Train for 1000 steps /home/ubuntu/tf2py/lib/python3.5/site-packages/tensorflow_core/python/framework/indexed_slices.py:424: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory. "Converting sparse IndexedSlices to a dense Tensor of unknown shape. " /home/ubuntu/tf2py/lib/python3.5/site-packages/tensorflow_core/python/framework/indexed_slices.py:424: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory. "Converting sparse IndexedSlices to a dense Tensor of unknown shape. " 2019-11-18 07:25:42.524686: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcublas.so.10.0 INFO:tensorflow:BenchmarkMetric: {'epoch':0, 'time_taken': 91.634508} I1118 07:26:44.871305 139963829905152 keras_utils.py:93] BenchmarkMetric: {'epoch':0, 'time_taken': 91.634508} Traceback (most recent call last): File "official/transformer/v2/transformer_main.py", line 474, in app.run(main) File "/usr/local/lib/python3.5/dist-packages/absl/app.py", line 299, in run _run_main(main, args) File "/usr/local/lib/python3.5/dist-packages/absl/app.py", line 250, in _run_main sys.exit(main(argv)) File "official/transformer/v2/transformer_main.py", line 463, in main _run_task(task) File "official/transformer/v2/transformer_main.py", line 454, in _run_task task.train() File "official/transformer/v2/transformer_main.py", line 329, in train verbose=(2 if flags_obj.enable_time_history else 1)) File "/home/ubuntu/tf2py/lib/python3.5/site-packages/tensorflow_core/python/keras/engine/training.py", line 728, in fit use_multiprocessing=use_multiprocessing) File "/home/ubuntu/tf2py/lib/python3.5/site-packages/tensorflow_core/python/keras/engine/training_v2.py", line 324, in fit total_epochs=epochs) File "/home/ubuntu/tf2py/lib/python3.5/site-packages/tensorflow_core/python/keras/engine/training_v2.py", line 174, in run_one_epoch step += 1 File "/usr/lib/python3.5/contextlib.py", line 66, in exit next(self.gen) File "/home/ubuntu/tf2py/lib/python3.5/site-packages/tensorflow_core/python/keras/engine/training_v2.py", line 700, in on_batch mode, 'end', step, batch_logs) File "/home/ubuntu/tf2py/lib/python3.5/site-packages/tensorflow_core/python/keras/callbacks.py", line 235, in _call_batch_hook batch_hook(batch, logs) File "/home/ubuntu/tf2py/lib/python3.5/site-packages/tensorflow_core/python/keras/callbacks.py", line 518, in on_train_batch_end self.on_batch_end(batch, logs=logs) File "/mnt/data/models/official/utils/misc/keras_utils.py", line 80, in on_batch_end examples_per_second = (self.batch_size * self.log_steps) / elapsed_time TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

Note:PARAM_SET is base

tkngoutham avatar Nov 18 '19 07:11 tkngoutham

Thank you for your post. We noticed you have not filled out the following field in the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Thanks. What is the top-level directory of the model you are using Have I written custom code OS Platform and Distribution TensorFlow installed from TensorFlow version Bazel version CUDA/cuDNN version GPU model and memory Exact command to reproduce

tensorflowbutler avatar Nov 19 '19 00:11 tensorflowbutler

It should be one of self.batch_size * self.log_steps is None. Do you set batch_size and log_steps flags correctly?

saberkun avatar Dec 04 '19 06:12 saberkun

batch_size is 1024 and log_steps I left it to default

tkngoutham avatar Dec 18 '19 08:12 tkngoutham

Both FLAGS.batch_size and FLAGS.log_steps cannot be None. Please checkout the master branch or recent releases.

saberkun avatar May 15 '20 17:05 saberkun