79414160

Date: 2025-02-05 09:01:40
Score: 0.5
Natty:
Report link

The error arises because tensorflow cannot determine the tensor shapes explicitly. When using tf.data.Dataset.from_generator, you should provide an output_signature argument to explicitly define the shape and type of the output tensors. This allows tensorflow to properly handle the data.

Instead of using this:

ds = tf.data.Dataset.from_generator(generator, 
                        output_types=({'LoB': tf.int32}, tf.float32))

Use this:

ds = tf.data.Dataset.from_generator(generator, output_signature=(
    {'LoB': tf.TensorSpec(shape=(1,), dtype=tf.int32)},
    tf.TensorSpec(shape=(1,), dtype=tf.float32)
))

please refer to this document for more details.

Reasons:
  • Blacklisted phrase (1): this document
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Sagar