Model.fit_generator(generator=train_data_generator, steps_per_epoch=num_batches, epochs=epochs, verbose=1)Īs implied by giser_yugang in a comment, it is also possible to do it with my_input_fn() as a function returning the dataset instead of the individual batches. Train_data_generator = my_input_fn(total_items, epochs) Num_batches = int(total_items/batch_size) I'll post it here in case it is useful to anyone in a similar situation.īasically, I changed the my_input_fn() into a generator and used model.fit_generator() as follows: import tensorflow as tfĭataset = tf._generator(lambda: my_generator(total_items), While the origin of the errors is still nebulous, I have found a solution that makes the code work. I am puzzled by these error messages and I would appreciate if anyone can shed some light on them, or point out what I am doing wrong. Yet batch_size is not a recognized keyword for fit_generator(). ValueError: You must specify `batch_size` Raise ValueError('You must specify `batch_size`') TypeError: _int_ returned non-int (type NoneType)Īnd on TF 2.0 I get the following error: Traceback (most recent call last):įile "~/.local/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 1515, in fit_generatorįile "~/.local/lib/python3.7/site-packages/tensorflow/python/keras/engine/training_generator.py", line 140, in model_iterationįile "~/.local/lib/python3.7/site-packages/tensorflow/python/keras/engine/training_generator.py", line 477, in convert_to_generator_like Num_samples = int(nest.flatten(data).shape) On TF 1.13.1 I get the following error: Traceback (most recent call last):įile "~/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 1426, in fit_generatorįile "~/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_generator.py", line 115, in model_iterationįile "~/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_generator.py", line 377, in convert_to_generator_like I tried changing model.fit() to model.fit_generator() but this fails on both TensorFlow versions too. ValueError: Arguments and signature arguments do not match: 21 23 Outputs = self._inference_function.call(ctx, args)įile "~/.local/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 397, in call Outputs = self._graph_fn(*converted_inputs)įile "~/.local/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 558, in _call_įile "~/.local/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 627, in _call_flat I tried running the same code on a different machine using TensorFlow 2.0 (after removing the line tf.enable_eager_execution() because it runs eagerly by default) and I got the following error: Traceback (most recent call last):įile "~/.local/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 873, in fitįile "~/.local/lib/python3.7/site-packages/tensorflow/python/keras/engine/training_arrays.py", line 352, in model_iterationįile "~/.local/lib/python3.7/site-packages/tensorflow/python/keras/backend.py", line 3217, in _call_ _impl.InvalidArgumentError: Attr shrink_axis_mask has value 4294967295 out of range for an int32 name: strided_slice/ _six.raise_from(_core._status_to_exception(e.code, message), None) Return for x in arrays]įile "~/.local/lib/python3.6/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 526, in įile "~/.local/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 654, in _slice_helperįile "~/.local/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 820, in strided_sliceįile "~/.local/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 9334, in strided_slice Ins_batch = slice_arrays(ins, batch_ids) + ]įile "~/.local/lib/python3.6/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 526, in slice_arrays The code fails using TensorFlow 1.13.1 at the model.fit() call with the following error: Traceback (most recent call last):įile "scripts/min_working_example.py", line 37, in įile "~/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 880, in fitįile "~/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_arrays.py", line 310, in model_iteration Iterator = dataset.make_one_shot_iterator()īatch_features, batch_labels = iterator.get_next() Here is a minimum working example of my code: import tensorflow as tfĭataset = tf._generator(lambda: my_generator(), I am using the Dataset API to generate training data and sort it into batches for a NN.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |