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' hot 8
Error occurred when finalizing GeneratorDataset iterator hot 6
ModuleNotFoundError: No module named 'tensorflow.contrib'
When importing TensorFlow, error loading Hadoop
tf.keras.layers.Conv1DTranspose ?
tensorflow-gpu CUPTI errors hot 4
[TF 2.0] tf.keras.optimizers.Adam hot 4
Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning. hot 4
TF2.0 AutoGraph issue hot 4
Tf.Keras metrics issue hot 4
Error loading tensorflow hot 4
module 'tensorflow' has no attribute 'ConfigProto' hot 4
TF 2.0 'Tensor' object has no attribute 'numpy' while using .numpy() although eager execution enabled by default hot 4
ModuleNotFoundError: No module named 'tensorflow.examples.tutorials' hot 4
AttributeError: module &#39;tensorflow.python.framework.op_def_registry&#39; has no attribute &#39;register_op_list&#39; hot 4
Github User Rank List