Im Trying to train a model and im getting a error like this
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(100,100,3)),
tf.keras.layers.Dense(128, activation="relu" ),
tf.keras.layers.Dense(4)
])
Loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)
Optimizer = tf.keras.optimizers.Adam(learning_rate=0.001)
model.compile(optimizer=Optimizer,
loss=Loss,
metrics=['accuracy'])
history = model.fit(X_train, y_train, epochs=10)
Im getting error at history
:
ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray).
I found the reason for error its becuase of X_train.shape
its output is (21,)
i shoud get something simliar to like (21, 100, 100, 3)
How can i convert that?
Edit:
X_train[0] return this
Shape of this is (179, 282, 3)
Dats In that is
array([[[0.15686275, 0.2 , 0.14509804],
[0.15686275, 0.18823529, 0.12941176],
[0.21176471, 0.23921569, 0.17647059],
...,
[0.9372549 , 0.95686275, 0.97254902],
[0.9372549 , 0.94901961, 0.96862745],
[0.95294118, 0.96470588, 0.98431373]],
[[0.18039216, 0.21176471, 0.16078431],
[0.12156863, 0.14509804, 0.09019608],
[0.16470588, 0.18039216, 0.12156863],
...,
[0.89411765, 0.91372549, 0.92941176],
[0.97647059, 0.98823529, 1. ],
[0.97647059, 0.98823529, 1. ]],
[[0.22352941, 0.25490196, 0.20392157],
[0.12156863, 0.14509804, 0.09019608],
[0.13333333, 0.14117647, 0.08627451],
...,
[0.87058824, 0.88235294, 0.90196078],
[0.98823529, 1. , 1. ],
[0.99607843, 1. , 1. ]],
...,
[[0.16862745, 0.29019608, 0.05882353],
[0.23921569, 0.34509804, 0.1372549 ],
[0.23137255, 0.31764706, 0.1372549 ],
...,
[0.2 , 0.31764706, 0.16862745],
[0.58431373, 0.7372549 , 0.41176471],
[0.55294118, 0.74117647, 0.27058824]],
[[0.21176471, 0.33333333, 0.10196078],
[0.27843137, 0.38431373, 0.17647059],
[0.2745098 , 0.36078431, 0.18039216],
...,
[0.27843137, 0.39607843, 0.24705882],
[0.62352941, 0.77647059, 0.45098039],
[0.59215686, 0.78039216, 0.30980392]],
[[0.23529412, 0.35686275, 0.1254902 ],
[0.29803922, 0.40392157, 0.19607843],
[0.29803922, 0.38431373, 0.20392157],
...,
[0.31764706, 0.43529412, 0.29411765],
[0.55294118, 0.70588235, 0.38039216],
[0.52156863, 0.70980392, 0.23921569]]])