I'm using the following code to try and learn tensorflow. I've clearly specified the shapes of the training and validation X
and y
arrays.
import numpy as np
import tensorflow as tf
f = lambda x: 2*x
Xtrain = np.random.rand(400,1)
ytrain = f(Xtrain)
Xval = np.random.rand(200,1)
yval = f(Xval)
model = tf.keras.models.Sequential([
tf.keras.layers.Dense(10, activation='relu'),
tf.keras.layers.Dense(10, activation='relu'),
tf.keras.layers.Dense(10, activation='relu'),
tf.keras.layers.Dense(10, activation='relu')
])
model.compile(optimizer='adam',
loss=tf.keras.losses.MeanSquaredError()
)
model.fit(Xtrain, ytrain, epochs=50, verbose=0)
When I run yval.shape, model.predict(Xval).shape
, I get the output ((200, 1), (200, 10))
. I'm not able to understand where these extra 9 dimensions are coming from. Even the Xval
prediction should have the shape (200, 1)
.