In the training modules, the max_embedding variables are not initialized with any matrix. In rare cases, the evaluated metric scores never increase and the branch in if acc > acc_max: is never excuted. An exception would be raised when it reaches line max_embedding = max_embedding[sort_indices] because the variable was never assigned.
As users, we prefer the program to run without exception and return results even though the metric scores are low and the embeddings are bad.
A possible solution is to initialize acc_max to -1. Therefore, whatever the actual accuracy is, the branch in if acc > acc_max: will always be executed and extra initializations will not be needed.
In the training modules, the
max_embedding
variables are not initialized with any matrix. In rare cases, the evaluated metric scores never increase and the branch inif acc > acc_max:
is never excuted. An exception would be raised when it reaches linemax_embedding = max_embedding[sort_indices]
because the variable was never assigned.As users, we prefer the program to run without exception and return results even though the metric scores are low and the embeddings are bad.
A possible solution is to initialize
acc_max
to-1
. Therefore, whatever the actual accuracy is, the branch inif acc > acc_max:
will always be executed and extra initializations will not be needed.