【发布时间】:2020-09-13 06:33:57
【问题描述】:
我有模型,看起来像这样:
Model: "sequential_4"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d_170 (Conv2D) (None, 256, 256, 32) 320
_________________________________________________________________
batch_normalization_169 (Bat (None, 256, 256, 32) 128
_________________________________________________________________
activation_166 (Activation) (None, 256, 256, 32) 0
_________________________________________________________________
conv2d_171 (Conv2D) (None, 256, 256, 32) 9248
_________________________________________________________________
batch_normalization_170 (Bat (None, 256, 256, 32) 128
_________________________________________________________________
activation_167 (Activation) (None, 256, 256, 32) 0
_________________________________________________________________
max_pooling2d_35 (MaxPooling (None, 128, 128, 32) 0
..............
但它给了我:
ValueError: Input 0 of layer sequential_4 is incompatible with the layer: expected axis -1 of input shape to have value 1 but received input with shape [None, 256, 256, 3]
我的图片的属性:
print(imm.dtype) # float32
print(imm.ndim) # 3
print(imm.shape) # (256, 256, 3)
此错误出现在:
history = model.fit(
x = train_x, y = train_y,
#batch_size=32,
#epochs=epochs,
#verbose=1,
#shuffle=True,
#validation_split=0.2
)
追踪:
ValueError Traceback (most recent call last)
<ipython-input-36-bf5138504d79> in <module>()
2
3 history = model.fit(
----> 4 x = train_x, y = train_y,
5 #batch_size=32,
6 #epochs=epochs,
当我从模型拟合中删除单个注释时,错误会下降一行。
【问题讨论】:
标签: tensorflow keras tensorflow2.0 keras-layer