Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

移除Accuracy之后,Fluid怎么使用了? #8942

Closed
yeyupiaoling opened this issue Mar 9, 2018 · 8 comments
Closed

移除Accuracy之后,Fluid怎么使用了? #8942

yeyupiaoling opened this issue Mar 9, 2018 · 8 comments
Labels
User 用于标记用户问题

Comments

@yeyupiaoling
Copy link
Contributor

yeyupiaoling commented Mar 9, 2018

我使用了最新的PaddlePaddle,在使用Fluid的时候发现报错

accuracy = fluid.evaluator.Accuracy(input=out, label=label)
AttributeError: 'module' object has no attribute 'Accuracy'

一步步查看才知道在 #8643 已经去掉了Accuracy,那么https://github.com/PaddlePaddle/models/blob/df8060e7022fcac12fd33a8adf098c0663d8152d/fluid/image_classification/mobilenet.py 这个例子怎办?
比如这些怎么处理

accuracy = fluid.evaluator.Accuracy(input=out, label=label)

accuracy.reset(exe)

pass_acc = accuracy.eval(exe)
@peterzhang2029 peterzhang2029 added the User 用于标记用户问题 label Mar 10, 2018
@peterzhang2029
Copy link
Contributor

新的accuracy接口使用可见示例:

batch_acc = fluid.layers.accuracy(input=predict, label=label, total=batch_size)
上述例子的模型有的还在完善当中,会陆续进行修改的。

@yeyupiaoling
Copy link
Contributor Author

yeyupiaoling commented Mar 10, 2018

@peterzhang2029
怎么又多了这两行代码,其中batch_size 是否可以手动指定为128,batch_acc 有何用处的?

batch_size = fluid.layers.create_tensor(dtype='int64')
batch_acc = fluid.layers.accuracy(input=predict, label=label, total=batch_size)

然后是应该使用


代替

 accuracy = fluid.layers.Accuracy(input=out, label=label)

吗?

测试的如果创建test_accuracy,之前版本为

with fluid.program_guard(inference_program):
    test_accuracy = fluid.evaluator.Accuracy(input=out, label=label)
    test_target = [avg_cost] + test_accuracy.metrics + test_accuracy.states
    inference_program = fluid.io.get_inference_program(test_target)

@peterzhang2029
Copy link
Contributor

peterzhang2029 commented Mar 10, 2018

batch_size在对每个batch计算的时候能取到当前batch里面样本的个数,而不是手动设置的全局的batch_size, 从而来求平均的准确率,batch_acc就是用来计算当前一个batch的平均acc结果。具体可以在迭代的时候输出结果看一下,如果需要test_accuracy可以参考 https://github.com/JiayiFeng/Paddle/blob/ea508c9ef276192e66ac93b8ea48af2e76385d2d/benchmark/cluster/vgg16/vgg16_fluid.py#L146

@yeyupiaoling
Copy link
Contributor Author

@peterzhang2029
batch_size是否可以手动指定为128,例子的是这样的

还有优化方法好像没有使用到

optimizer = fluid.optimizer.Adam(learning_rate=0.001)
opts = optimizer.minimize(avg_cost)

@JiayiFeng
Copy link
Collaborator

@yeyupiaoling 你好,非常抱歉我们在去掉Fluid中的Accuracy之后,没有对models中的例子进行及时更新,对您的使用造成了困扰。

对models中例子的更新已经开始,估计这两天就可以发出pr。pr merge后,我会在这个issue下回复告知。

再次感谢您对Paddle Fluid的关注,谢谢!

@yeyupiaoling
Copy link
Contributor Author

@JiayiFeng
哈哈,通过不断提issue,我已经跑通了训练部分,但是预测部分还是不懂,请赐教 #8938

@yeyupiaoling
Copy link
Contributor Author

@peterzhang2029 @JiayiFeng
能否也解答这个问题PaddlePaddle/models#703 (comment)

@wangkuiyi
Copy link
Collaborator

非常感谢 @yeyupiaoling 的这些 issue和这些讨论。不仅帮助paddlepaddle团队定位问题,督促我们完善系统,也让日后碰到类似的问题的朋友们可以通过搜索issues内容得到答案。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
User 用于标记用户问题
Projects
None yet
Development

No branches or pull requests

4 participants