Training using tf.Dataset in TensorFlow 2.0
Created#More Posted time:Jan 20, 2023 19:32 PM
I'm having difficulty training my TensorFlow model using a tf.Dataset rather than, say, a pd.DataFrame (which works fine).
I have created a dummy example below that I would expect to work on given what I have read online/on the TensorFlow Certification.
!pip install tensorflow==2.0.0 > /dev/null
import numpy as np
import tensorflow as tf
features, target = np.random.rand(100, 30), np.random.randint(0, 2, 100)
dataset = tf.data.Dataset.from_tensor_slices((features, target))
model = tf.keras.Sequential([
tf.keras.layers.Dense(30, activation='relu', input_shape=(30,)),
which returns the following error message
ValueError: Error when checking input: expected dense_input to have shape (30,) but got array with shape (1,)
Is there anything obviously wrong in the above? Why is TensorFlow grabbing an input with shape (1,)?