在Keras Python中调整输出层的大小

我的目标是将输出图像的大小从 [32,32,1] 调整为 [8,8,1]

我尝试重塑,但出现了错误:

Output_model = Reshape((8,-1))(out_1)
Error when checking target: expected reshape_1 to have shape (8,32) but got array with shape (32,1)

我该如何解决这个问题?

非常感谢

xuyin19881101 回答:在Keras Python中调整输出层的大小

由于32 * 32 * 1不等于8 * 8 * 1,因此无法直接重塑数组,因此必须进行二次采样:

import keras
x=keras.layers.Input((32,32,1))
x=keras.layers.MaxPooling2D((4,4))(x)

然后您的图像将降采样为(8,8,1)。

本文链接:https://www.f2er.com/3085729.html

大家都在问