python - 在 Keras Python 中调整输出层的大小
问题描述
我的目标是将输出图像的大小从[32,32,1]调整为[8,8,1]
我尝试使用 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)
我怎么解决这个问题??
非常感谢
解决方案
您不能直接重塑数组,因为 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)。
推荐阅读
- vb.net - 如何解决——无效的索引。(来自 HRESULT 的异常:0x8002000B (DISP_E_BADINDEX))?
- perl - 如何只切片定义的值?
- android - kotlin 从不同的 kotlin 类文件开始新活动
- python - 使用 if 条件从现有 CSV 创建列
- java - Spring Cloud Sleuth 无法识别记录中的跟踪并将其放入跟踪上下文中
- c++ - 向 AVL 树中的节点添加数据(将对推送到对列表)无法正常工作
- python - 为 MS 团队使用 python 将变量加载到 json 字符串中
- python - .is_valid() 方法,但在使用 ajax 时不验证
- c - 从文本文件中读取格式说明符
- c# - Newtosoft JSON 将零字符串值 ( {'name': '0'} ) 反序列化为 null?