i have this train and test code and i would like to see the loss and accuracy histogram but i don’t know how to do?
import torch
import cv2
import numpy as np
import glob
import scipy
import scipy.io as sio
from torch.utils.data import Dataset, DataLoader
device = torch.device(“cuda:0” if torch.cuda.is_available() else “cpu”)
Y=Convolution_opMS(imgNonOlive,(16,16),(6,6))#appel a la fonction de la preparation de donnèes
Y=Y.tolist() #list of samples  ‘non olive’
A=Convolution_opMS(imgolive,(16,16),(8,8))#appel a la fonction de la preparation de donnèes
A=A.tolist()  #list of samples  ‘olive’
#len(X)
#savemat(“olivecoup.mat”,{“fo”:X})
#print(‘number of data :’ ,len(X)+len(Y))
z=np.concatenate((A,Y))
z=z.tolist()  #list of samples  'alldata
labels=[]
alldata = z
net.eval()
class ImageDataset:
def __init__(self,alldata,  transform=None):

  

    #self.root_dir = root_dir

    #load data from mat files

    self.alldata=alldata

    #glob.glob(self.root_dir+"/*.mat")

    alldata_olivier = A

    alldata_non_olivier = Y

    #transform data to unique list of data

    

    #a list of label 

    #à) construire à partir [0 ou 1] selon self.alldata

    

    for i in range(1662) : #number of samples 'non olive'

        labels.append(0)

    for i in range(1958) : #number of samples 'olive

        labels.append(1)

    

    #shuffle data using sklearn

            

    self.numdata = 3620

    self.transform = transform

    

def __len__(self):

    return self.numdata

def __getitem__(self, idx):

    label=labels[idx]

    #newidx = self.shuffle[idx]

    image = self.alldata[idx]

    label=np.asarray(label)

    #transform data from numpy to torch tensor

    imageTensor =np.asarray(alldata)# 

    imageTensor =torch.from_numpy(imageTensor)

    #plt.imshow(imageTensor[:,:,0])

    labelTensor =np.asarray(labels)# torch.from_numpy(label)

    labelTensor =torch.from_numpy(labelTensor)

    #print(imageTensor)

    

    return imageTensor , labelTensor

if name == ‘main’:
k= ImageDataset(z)

k.__getitem__(60)

import sklearn.model_selection as model_selection
X_train, X_test, y_train, y_test = model_selection.train_test_split(alldata, labels, train_size=0.8,test_size=0.2, random_state=102)
class trainData():
def __init__(self, X_data, y_data):

    self.X_data = X_data

    self.y_data = y_data

    

def __getitem__(self, index):

    return self.X_data[index], self.y_data[index]

    

def __len__ (self):

    return len(self.X_data)

from torchvision import transforms
train_data = trainData(torch.FloatTensor(X_train),
                   torch.FloatTensor(y_train),

                   )

class testData():
def __init__(self, X_data):

    self.X_data = X_data

    

def __getitem__(self, index):

    return self.X_data[index]

    

def __len__ (self):

    return len(self.X_data)

test_data = testData(torch.FloatTensor(X_test))
EPOCHS = 120
LEARNING_RATE = 0.001
train_loader = DataLoader(dataset=train_data, batch_size=6, shuffle=True)
def binary_acc(y_pred, y_testt):
y_pred_tag = torch.round(y_pred)

correct_results_sum = (y_pred_tag[:,0]  == y_testt).sum().float()

acc = correct_results_sum/y_testt.shape[0]

acc = torch.round(acc * 100)



return acc

net.train()
for e in range(1, EPOCHS+1):
epoch_loss = 0

epoch_acc = 0

for X_batch, y_batch in train_loader:

            

    X_batch =np.asarray(X_batch)

    X_batch =torch.from_numpy(X_batch)

    optimizer.zero_grad()

    

    X_batch= X_batch.permute(0,3,2,1).float()

    y_batch =np.asarray(y_batch) 

    y_batch =torch.from_numpy(y_batch)

    y_pred = net(X_batch) 

    

    acc = binary_acc(y_pred, y_batch)

    

    loss = loss_fn(y_pred[:,0], y_batch.float())  

        

    loss.backward()

    

    optimizer.step()

    

    epoch_loss += loss.item()

            

    epoch_acc += acc.item()

    

print('debut training : ')   

print(f'Epoch {e+0:03}: | Loss: {epoch_loss/len(train_loader):.5f} | Acc: {epoch_acc/len(train_loader):.3f}')

#---------------------test--------------------------
test_loader = DataLoader(dataset=test_data)
y_pred_list = []
net.eval()
with torch.no_grad():
for X_batch1 in test_loader:

    

    X_batch1= X_batch1.permute(0,3,2,1).float()

    y_test_pred =net(X_batch1)

    y_pred_tag = torch.round(y_test_pred[0,:])

    y_pred_list.append(y_pred_tag.numpy())

y_pred_list = [a.squeeze().tolist() for a in y_pred_list]
y_pred_list =np.asarray(y_pred_list)
from sklearn.metrics import confusion_matrix
cm=confusion_matrix(y_test,y_pred_list[:,0].tolist())
error=(cm[0,1]+cm[1,0])/724
acc=(cm[0,0]+cm[1,1])/724