Skip to content

UnboundLocalError: local variable 'best_idx' referenced before assignment #1

@Salidor

Description

@Salidor

In Training phase i get this error:

UnboundLocalError                         Traceback (most recent call last)

<ipython-input-30-730ad33b5889> in <module>()
    110     model.train(False)  # evaluation을 위해, 훈련 X
    111     #global best_idx
--> 112     best_train_F, new_train_F, _,_ = evaluating(model, test_train_data, best_train_F, epoch)
    113     best_test_F,  new_test_F,  _,opts.best_idx = evaluating(model, test_data, best_test_F, epoch)
    114     # validation의 결과가 best면 save를 True로, 모델이 저장되도록

<ipython-input-29-76c9c4a8fd6b> in evaluating(model, datas, best_F, epoch, display_confusion_matrix)
    118     # new_F : 현재 sample의   F score
    119     # save  : 최고 F score를 갱신하면 save = True를 return
--> 120     return best_F, new_F, save, best_idx
    121     print(best_idx)

UnboundLocalError: local variable 'best_idx' referenced before assignment

Any idea how to solve it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions