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

Remove unnecessary null pointer checks #1

Closed
elfring opened this issue Jul 4, 2018 · 5 comments
Closed

Remove unnecessary null pointer checks #1

elfring opened this issue Jul 4, 2018 · 5 comments

Comments

@elfring
Copy link

elfring commented Jul 4, 2018

An extra null pointer check is not needed in functions like the following.

@csaimd
Copy link

csaimd commented Aug 3, 2018

eval的时候有问题,
for data in test_reader():
# infer a batch
pred = exe.run(inference_program,
feed=utils.data2tensor(data, place),
fetch_list=fetch_targets,
return_numpy=True)
for i, val in enumerate(data):
class3_label, class2_label = utils.get_predict_label(pred[0][i, 1])
true_label = val[1]
if class2_label == true_label:
class2_acc += 1
if class3_label == true_label:
class3_acc += 1
if true_label == 1.0:
neu_count += 1

        total_count += len(data)

    class2_acc = class2_acc / (total_count - neu_count)
    class3_acc = class3_acc / total_count

为什么for循环进不去,直接跑到class2_acc = class2_acc / (total_count - neu_count)
class3_acc = class3_acc / total_count,然后除数为零,就出问题了

@ChinaLiuHao
Copy link
Collaborator

test_reader()里是否塞数据了呢?

@csaimd
Copy link

csaimd commented Aug 3, 2018

解决了,batchsize在测试的时候设置为1,然后就好了

@csaimd
Copy link

csaimd commented Aug 3, 2018

默认batchsize=256,但是测试的例子中只有200条数据

@elfring
Copy link
Author

elfring commented Sep 29, 2018

Will any redundant null pointer checks be deleted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants