简体   繁体   中英

Resize Output Layer in Keras Python

my goal is to resize the output image from [32,32,1] to [8,8,1]

I try this with reshape but became a error:

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:

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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