我的版本、环境信息:
1)PaddlePaddle版本:paddlepaddle-gpu 1.8.0.post107
3)GPU:gtx950m ,cuda 10.2, V10.2.89
4)系统环境:py3.7+win10 家庭普通版
训练信息
1)单机,单卡
2)6169m
当运行
#先来尝试一下完全使用 ImageNet预训练的权重,效果怎样吧
test_program` = fluid.Program()
test_startup = fluid.Program()
with fluid.program_guard(test_program, test_startup):
with fluid.unique_name.guard():
image = fluid.layers.data(name='image', shape=(-1, 3, 224, 224), dtype='float32')
label = fluid.layers.data(name='label', shape=(-1, 1), dtype='int64')
_, fetch_list = create_network(image, label, is_test=True)
# 大家如果没有 GPU,可以将其改为 False
# 注意: CPU 中 PaddlePaddle 并不一定实现了所有的 Operator 的训练,一般建议大家使用 GPU
use_gpu = True
place = fluid.CUDAPlace(0) if use_gpu else fluid.CPUPlace()
exe = `fluid.Executor(place)
# 初始化一下 Executor
exe.run(program=test_startup)
# 载入预训练的模型参数
def _predicate(var):
# 查看 var 参数是不是在预训练模型路径内
return os.path.exists(os.path.join(pretrained_model_path, var.name))
fluid.io.load_vars(exe, pretrained_model_path, predicate=_predicate, main_program=test_program)
data = exe.run(program=test_program, fetch_list=fetch_list, feed={'image': images, 'label': labels})
# 把数据从 data 中取出来 (data 是一个列表,顺序与 fetch_list 相同)
image, label = data[0:2]
out, confidence, top5_scores, top5_indices = data[2:6]
loss, acc_top1, acc_top5 = data[6:]
display_batch(image)
print('ImageNet 预训练模型情况: loss=%06.3f top-1=%05.2f%% top-5=%05.2f%%' % (
loss, acc_top1 * 100, acc_top5 * 100))
log_topk_info(None, top5_scores, top5_indices)
# 之后要重新创建模型进行针对 Natural Images 的再训练,故这里的 Program 和 Executor 都不再需要了
exe.close()
报错为
TypeError Traceback (most recent call last)
<ipython-input-17-bb3713832880> in <module>
8 image = fluid.layers.data(name='image', shape=(-1, 3, 224, 224), dtype='float32')
9 label = fluid.layers.data(name='label', shape=(-1, 1), dtype='int64')
---> 10 _, fetch_list = create_network(image, label, is_test=True)
11
12 # 大家如果没有 GPU,可以将其改为 False
<ipython-input-13-3a2c2fad7823> in create_network(image, label, class_dim, is_test)
9
10 model = ResNet(is_test=is_test)
---> 11 out = model.net(image, class_dim=class_dim)
12
13 confidence = fluid.layers.softmax(out)
<ipython-input-12-9f956ea050fb> in net(self, input, class_dim)
49 initializer=fluid.initializer.Uniform(-stdv, stdv), trainable=True)
50 out = fluid.layers.fc(
---> 51 input=pool, size=class_dim, act=None, is_test=self.is_test, param_attr=fc_param_attr)
52
53 return out
TypeError: fc() got an unexpected keyword argument 'is_test'
不知道什么原因?能否解决下?请问您当时的paddle用的是哪个版本,可否告知下,由于您跑都没什么问题,我估计是环境问题,您当时18年录制时使用的paddle以及cuda是哪个版本?您看到了希望尽快回复,谢谢您了!
我的版本、环境信息:
1)PaddlePaddle版本:paddlepaddle-gpu 1.8.0.post107
3)GPU:gtx950m ,cuda 10.2, V10.2.89
4)系统环境:py3.7+win10 家庭普通版
训练信息
1)单机,单卡
2)6169m
当运行
报错为
不知道什么原因?能否解决下?请问您当时的paddle用的是哪个版本,可否告知下,由于您跑都没什么问题,我估计是环境问题,您当时18年录制时使用的paddle以及cuda是哪个版本?您看到了希望尽快回复,谢谢您了!