Getting Attribute Error TensorDataset object has no attribute 'output_shapes' issue

Viewed 21

Getting attribute error issue using tf.data.Dataset

import numpy as np
import tensorflow as tf

x, y = np.array([1, 2, 3, 4]), np.array([5, 6, 7, 8])
d = tf.data.Dataset.from_tensors((x,y))

print(d.output_shapes) 


AttributeError: 'TensorDataset' object has no attribute 'output_shapes'

Screenshot

How to find output shapes?

1 Answers

Use tf.data.Dataset.elementspec:

import numpy as np
import tensorflow as tf

x, y = np.array([1, 2, 3, 4]), np.array([5, 6, 7, 8])
d = tf.data.Dataset.from_tensors((x,y))
d.element_spec
(TensorSpec(shape=(4,), dtype=tf.int64, name=None),
 TensorSpec(shape=(4,), dtype=tf.int64, name=None))
Related