keras - keras 中的 preprocess_input 大大增加了火车的大小
问题描述
在使用 resnet50 模型进行训练之前,我使用以下方法预处理了我的输入:
img = image.load_img(os.path.join(TRAIN, img), target_size=[224, 224])
img = image.img_to_array(img)
img = np.expand_dims(img, axis=0)
img = preprocess_input(img)
并保存一个 numpy 图像数组。我发现没有preprocess_input
,数组的大小是1.5G,有preprocess_input,大小是7G。这是正常行为吗?还是我错过了什么?为什么Zero-center by mean pixel
大幅增加输入大小?
这就是zero center by mean pixel
在 keras 中定义的方式
x = x[..., ::-1]
x[..., 0] -= 103.939
x[..., 1] -= 116.779
x[..., 2] -= 123.68
解决方案
这是因为像素值的类型为“uint8”,而现在它们的类型为“float”。所以现在你有一个图像,它是一个'float'数组,它大于'uint8'数组。
推荐阅读
- selenium - Zalenium:OpenShift 环境中的 504 网关超时
- dart - Flutter 应用程序在构建版本中冻结,在调试中正常工作,androidX?
- node.js - PassportLocalDocument 和 PaginateModel 在同一个界面上?
- android - 如何在我的颤振应用程序中显示图像?我在做什么不工作
- python - Python 无法从两级深层子目录中找到名为 / 导入错误的模块
- linux-kernel - 这个声明是什么意思:int (*packet_xmit)(struct sk_buff *skb);?
- python - 如何将新行加入python数据框中的现有行
- jquery - 通过 jQuery 的 Ajax 请求与普通调用
- c# - 减去两个 ViewBag 值
- wordpress - 预加载 WooCommerce star.woff 字体