我尝试通过mlflow预测为mnist训练的模型
loaded_model = mlflow.pyfunc.load_model(logged_model)
(x_train, y_train), (x_test, y_test) = mnist.load_data()
我尝试通过
x = pd.DataFrame(x_test)
但我得到了
ValueError: Must pass 2-d input. shape=(10000, 28, 28)
但如果我重塑
xtest2 = x_test.reshape(10000, 784)
x = pd.DataFrame(xtest2)
loaded_model.predict(x)
输入未对齐
ValueError: Input 0 of layer "sequential_2" is incompatible with the layer: expected shape=(None, 28, 28), found shape=(None, 784)
这是有意义的,因为该层被设置为
model = tf.keras.Sequential([
tf.keras.layers.Conv2D(32, 3, activation='relu', input_shape=(28, 28, 1)),
但是如何同时满足panda要求和tensorflow 要求呢?
1条答案
按热度按时间agyaoht71#
您可以在调用
model.predict
之前尝试重新整形: