2021年3月3日星期三

Converting Image to Array For Tensorflow Model

Im Trying to train a model and im getting a error like this ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray).

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

I found the reason for error its becuase of X_train.shape its output is (21,) i shoud get something simliar to lie this ```(21, 100, 100, 3)```` How can i convert that?

https://stackoverflow.com/questions/66468431/converting-image-to-array-for-tensorflow-model March 04, 2021 at 12:07PM

没有评论:

发表评论