预期输入有4个维度,但有阵列形状

问题描述 投票:4回答:1

我有这个错误

检查输入时出错:预期input_13有4个维度,但得到的数组有形状(7,100,100)

对于以下代码,我应该如何重塑数组以适应4维,我搜索它但不理解以前的解决方案。请问如果不清楚它在卷积神经网络中的常见问题。

inputs=Input(shape=(100,100,1))

x=Conv2D(16,(3,3), padding='same')(inputs)
x=Activation('relu')(x)
x=Conv2D(8,(3,3))(x)
x=Activation('relu')(x)
x=MaxPooling2D(pool_size=(2,2))(x)
x=Dropout(0.2)(x)
x=Dense(num_classes)(x)
x=Activation('softmax')(x)
output=Activation('softmax')(x)
model=Model([inputs], output)
python-3.x deep-learning keras conv-neural-network keras-layer
1个回答
5
投票

如果x是您的数据数组,您应该只应用以下转换:

x = x.reshape((-1, 100, 100, 1))
© www.soinside.com 2019 - 2024. All rights reserved.