profile
viewpoint

Ask questionsIncorrect Error TypeError: padded_batch() missing 1 required positional argument: 'padded_shapes'

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Error is not OS specific. Can be reproduced in Google Colab.
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A
  • TensorFlow installed from (source or binary): N/A
  • TensorFlow version (use command below): %tensorflow_version 2.x
  • Python version: 3.6
  • Bazel version (if compiling from source): N/A
  • GCC/Compiler version (if compiling from source): N/A
  • CUDA/cuDNN version: N/A
  • GPU model and memory: N/A
  • Exact command to reproduce: Please find this Github Gist

Describe the problem

As per the Source Code of Padded_Batch, only the Argument, batch_size is Mandatory and remaining arguments are Optional. But as per the code in this Tutorial, if we don't pass the second argument, padded_shapes = ([None],()) it is resulting in the below error, TypeError: padded_batch() missing 1 required positional argument: 'padded_shapes'

Error Log:

TypeError Traceback (most recent call last) <ipython-input-9-a8afa0f91afc> in <module>() ----> 1 train_batches = train_data.shuffle(1000).padded_batch(10) 2 test_batches = test_data.shuffle(1000).padded_batch(10) 3 4 #Error will be resolved if we uncomment below 3 lines and comment above 2 lines 5

TypeError: padded_batch() missing 1 required positional argument: 'padded_shapes'

Expected Behavior: Since the argument, padded_shapes is an Optional Argument, it shouldn't result in error even when we pass only the argument, batch_size

tensorflow/tensorflow

Answer questions ymodak

tf.data.Dataset.padded_batch method requires two arguments. Note see stable 2.1, version https://github.com/tensorflow/tensorflow/blob/r2.1/tensorflow/python/data/ops/dataset_ops.py#L1383 https://www.tensorflow.org/api_docs/python/tf/data/Dataset#padded_batch

useful!

Related questions

ModuleNotFoundError: No module named 'tensorflow.contrib'
Error occurred when finalizing GeneratorDataset iterator
ModuleNotFoundError: No module named 'tensorflow.contrib'
When importing TensorFlow, error loading Hadoop hot 4
The flag 'log_dir' is defined twice. hot 3
[TF 2.0] Dataset has no attribute 'make_one_shot_iterator' hot 3
Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning. hot 3
TF2.0 AutoGraph issue hot 3
Error loading tensorflow hot 3
AttributeError: module 'tensorflow' has no attribute 'set_random_seed' hot 3
No tf.lite.experimental.nn.bidirectional_dynamic_rnn ops is finded hot 3
AttributeError: module 'tensorflow' has no attribute 'app' hot 3
tensorflow2.0 detected 'xla_gpu' , but 'gpu' expected hot 2
Using tensorflow gpu 2.1 with Cuda 10.2 hot 2
Restoring Keras model fails inside a distribution strategy scope hot 2
Github User Rank List