简体   繁体   English

在 Keras Python 中调整 Output 层的大小

[英]Resize Output Layer in Keras Python

my goal is to resize the output image from [32,32,1] to [8,8,1]我的目标是将 output 图像从[32,32,1]调整为[8,8,1]

I try this with reshape but became a error:我尝试使用 reshape 进行此操作,但出现错误:

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

How can I solve this problem??我怎么解决这个问题??

Thanks a lot非常感谢

you cannot reshape the array directly because 32*32*1 not equal to 8*8*1, therefore you have to subsample:您不能直接重塑数组,因为 32*32*1 不等于 8*8*1,因此您必须进行子采样:

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

then your image will downsample to (8,8,1).然后您的图像将下采样到(8,8,1)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM