此代码引发可被 0 整除的错误
for key in results_dic:
# match (if dog then breed match)
if results_dic[key][2] == 1:
# isa dog (pet label) & breed match
if results_dic[key][3] == 1:
n_pet_dog += 1
# isa dog (classifier label) & breed match
if results_dic[key][4] == 1:
n_class_cdog += 1
n_match_breed += 1
# NOT dog (pet_label)
else:
# NOT dog (classifier label)
if results_dic[key][4] == 0:
n_class_cnotd += 1
# NOT - match (not a breed match if a dog)
else:
# NOT - match
# isa dog (pet label)
if results_dic[key][3] == 1:
n_pet_dog += 1
# isa dog (classifier label)
if results_dic[key][4] == 1:
n_class_cdog += 1
# NOT dog (pet_label)
else:
# NOT dog (classifier label)
if results_dic[key][4] == 0:
n_class_cnotd += 1
# calculates statistics based upon counters from above
n_pet_notd = n_images - n_pet_dog
pct_corr_dog = ( n_class_cdog / n_pet_dog )*100
pct_corr_notdog = ( n_class_cnotd / n_pet_notd )*100
pct_corr_breed = ( n_match_breed / n_pet_dog )*100
即使我使用if-else语句,它也会抛出相同的错误,我应该使用异常语句,我怎么能在这种情况下使用它,我已经被告知这是因为缩进错误,但我检查了它,它应该没有问题
Cats萌萌
手掌心
蓝山帝景
相关分类