Replies: 2 comments
-
I also had this error. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Can you please explain how we change (-1,1) to other values according to the model... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
int this below code when i was following your video code its showing error --> its showing error that mx_ndim==2 and found==1 in fit model at step 3 : 3.1--error and 3.2 --> is runs
why???
import numpy as np
import matplotlib.pyplot as plt
create features
X= np.array([-7.0, -4.0, -1.0, 2.0, 5.0, 8.0, 11.0, 14.0,])
Create labels
y= np.array([3.0, 6.0, 9.0, 12.0, 15.0, 18.0, 21.0 ,24.0])
turn our Numpy arrays into tensor
X= tf.cast(tf.constant(X),dtype=tf.float32)
y= tf.cast(tf.constant(y), dtype=tf.float32)
tf.random.set_seed(42)
1. creating a model using sequential API
model =tf.keras.Sequential([
tf.keras.layers.Dense(1)
])
2 . Compile the model
model.compile(loss= tf.keras.losses.mae, # mae i short form of mean absolute error
optimizer= tf.keras.optimizers.SGD(),
# SGD= stochastic gradient descent
metrics=["mae"]
3. Fit the model
3.1 ===> model.fit(X,y,epochs=5);
3.2==> model.fit(tf.reshape(X,shape=(-1,1)),y, epochs=5)
Beta Was this translation helpful? Give feedback.
All reactions