Hi,
I’ve saved my model train and validation accuracy using with open( )... as f , f.close()
in .txt
format. The output is like this:
tensor(0.3494, device='cuda:0', dtype=torch.float64)
tensor(0.4721, device='cuda:0', dtype=torch.float64)
tensor(0.5966, device='cuda:0', dtype=torch.float64)
tensor(0.7131, device='cuda:0', dtype=torch.float64)
tensor(0.8192, device='cuda:0', dtype=torch.float64)
tensor(0.9051, device='cuda:0', dtype=torch.float64)
tensor(0.9604, device='cuda:0', dtype=torch.float64)
.
.
.
Now I want to plot the results:
accs_trn = np.loadtxt('Test/accs_trn.txt', dtype=float)
accs_val = np.loadtxt('Test/accs_val.txt', dtype=float)
plt.figure(figsize=(12, 4))
plt.plot(accs_trn[0][0])
plt.plot(accs_val[0][0])
plt.xlabel('Iteration')
plt.ylabel('Accuracy')
plt.title('model')
plt.show()
But I get this error:
ValueError: could not convert string to float: 'tensor(0.3494,'
I know what this error means but I don’t know how to handle it.
Can you please help me with how to use these .txt
files to plot?