desc += 'acc: %.3f, TP: %.3f, TN: %.3f, FN: %.3f, FP: %.3f' % ( (TP.item() + TN.item()) * 1.0 / TOT.item(), TP.item() * 1.0 / TOT.item(), TN.item() * 1.0 / TOT.item(), FN.item() * 1.0 / TOT.item(), FP.item() * 1.0 / TOT.item()) running_loss += loss.item() * n_batches nbre_sample += n_batches #print(ok) epoch_loss = running_loss / nbre_sample acc = (TP.item() + TN.item()) * 1.0 / TOT.item() nn_model_ref.acc = acc print('{} Loss: {:.4f}'.format( phase, epoch_loss)) print('{} Acc: {:.4f}'.format( phase, acc)) #print(desc) print() time_elapsed = time.time() - since print('Evaluation complete in {:.0f}m {:.0f}s'.format( time_elapsed // 60, time_elapsed % 60)) print() from sklearn.model_selection import cross_val_score from sklearn import svm
#del data_ici #nn_model_ref2.intermediaires[phase].append(nn_model_ref2.net.intermediare.detach().cpu().numpy().astype(np.uint8)) #nn_model_ref2.outputs_proba[phase].append(outputs.detach().cpu().numpy().astype(np.float16)) nbre_sample += n_batches epoch_loss = running_loss / nbre_sample acc1 = (correct1.item()) * 1.0 / TOT21.item() acc2 = (correct2.item()) * 1.0 / TOT22.item() acc3 = (correct3.item()) * 1.0 / TOT23.item() acc4 = (correct4.item()) * 1.0 / TOT24.item() #acc = (correct1.item() + correct2.item()) * 1.0 / (TOT22.item() + TOT21.item()) acc = (correct1.item() + correct2.item() + correct3.item() + correct4.item()) * 1.0 / (TOT22.item() + TOT21.item() + TOT23.item() + TOT24.item()) nn_model_ref2.acc = acc print('{} Loss: {:.4f}'.format(phase, epoch_loss)) print('{} Acc: {:.4f}'.format(phase, acc1)) print('{} Acc: {:.4f}'.format(phase, acc2)) print('{} Acc: {:.4f}'.format(phase, acc3)) print('{} Acc: {:.4f}'.format(phase, acc4)) print('{} Acc FINAL: {:.4f}'.format(phase, acc)) #print(desc) print() time_elapsed = time.time() - since print('Evaluation complete in {:.0f}m {:.0f}s'.format( time_elapsed // 60, time_elapsed % 60)) print() num1 = int(nn_model_ref2.args.nbre_sample_train_classifier / nn_model_ref2.batch_size) num2 = int(nn_model_ref2.args.nbre_sample_val_classifier /