Hi there,
I would like to write a simple NN model to predict the housing price. My dataset is simple, and the X-train has one feature: the house’s surface, and i want to predict its price.
Here is the code. Any hints?
Xt = np.array([[1.0], [2.0]], dtype=np.float32) #(size in 1000 square feet)
Yt = np.array([[300.0], [500.0]], dtype=np.float32) #(price in 1000s of dollars)
norm_l = tf.keras.layers.Normalization(axis=-1)
norm_l.adapt(Xt) # learns mean, variance
#Xn = norm_l(Xt)
Xt = np.tile(Xn,(1000,1))
Yt= np.tile(Yt,(1000,1))
tf.random.set_seed(1234)
model = Sequential(
[
tf.keras.layers.Dense(units=1, activation = ‘ReLU’, name=‘L1’ ),
tf.keras.layers.Dense(units=2, activation = ‘ReLU’, name=‘L2’ ),
tf.keras.layers.Dense(units=1, activation = ‘linear’, name=‘L3’ )
]
)
model.compile(
loss = tf.keras.losses.MeanSquaredError(),
optimizer = tf.keras.optimizers.Adam(learning_rate=0.01),
)
model.fit(
Xt,Yt,
epochs=100,
)
result=model.predict([[2.0]])
print(result)
Thank you for your help