提交 e7ff265b 编写于 作者: L liuhui29

reader加载自己的数据时,需要考虑是否减掉mean值

上级 0e89ccbb
......@@ -10,7 +10,10 @@ def train_mapper(sample):
'''
img, label = sample
img = paddle.image.load_image(img)
img = paddle.image.simple_transform(img, 256, 224, True)
# https://github.com/PaddlePaddle/Paddle/blob/d52fa26fdab7a0497a3e7f49833d1b3827955c44/python/paddle/v2/dataset/flowers.py#L65
# mean:根据加载的预训练模型的mean设置。如果不加载预训练模型,则根据自己喜好设置
# paddlepaddle的代码中,默认减去这个mean值,如果加载的预训练模型使用的mean与这个值不一样,需要修改
img = paddle.image.simple_transform(img, 256, 224, True, mean=[103.94, 116.78, 123.68])
return img.flatten().astype('float32'), label
......@@ -20,7 +23,8 @@ def test_mapper(sample):
'''
img, label = sample
img = paddle.image.load_image(img)
img = paddle.image.simple_transform(img, 256, 224, True)
# 同上
img = paddle.image.simple_transform(img, 256, 224, True, mean=[103.94, 116.78, 123.68])
return img.flatten().astype('float32'), label
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册