Custom Dataset changing the values of my data

Hello everyone I have a data of this type

       0    1    2    3    4    5    6    7    8    9  ...   58   59   60   61   62   63    T      M       E             S
0     0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  1.0  0.0  ...  0.0  0.0  0.0  0.0  0.0  0.0  2.9 -0.080 -62.959  1.698111e+09
1     1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  ...  1.0  1.0  1.0  1.0  0.0  1.0  2.9  0.126 -62.845  1.698109e+09
2     0.0  0.0  1.0  1.0  0.0  0.0  0.0  0.0  0.0  0.0  ...  0.0  0.0  0.0  1.0  0.0  0.0  2.9  0.055 -62.992  1.698109e+09
3     1.0  0.0  0.0  0.0  0.0  1.0  0.0  0.0  1.0  1.0  ...  0.0  1.0  0.0  0.0  0.0  0.0  2.9  0.063 -62.910  1.698112e+09
4     1.0  0.0  1.0  1.0  1.0  0.0  1.0  1.0  1.0  1.0  ...  1.0  1.0  1.0  1.0  1.0  1.0  2.9 -0.120 -62.890  1.698106e+09
...   ...  ...  ...  ...  ...  ...  ...  ...  ...  ...  ...  ...  ...  ...  ...  ...  ...  ...    ...     ...           ...
4995  0.0  1.0  1.0  0.0  1.0  1.0  1.0  0.0  0.0  0.0  ...  1.0  0.0  1.0  0.0  0.0  0.0  2.9  0.100 -62.919  1.698110e+09
4996  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  ...  1.0  1.0  1.0  1.0  1.0  0.0  2.9 -0.068 -62.917  1.698110e+09
4997  1.0  0.0  0.0  1.0  1.0  1.0  1.0  1.0  0.0  0.0  ...  1.0  1.0  1.0  0.0  0.0  0.0  2.9  0.163 -62.816  1.698112e+09
4998  0.0  0.0  0.0  0.0  0.0  1.0  1.0  1.0  0.0  0.0  ...  1.0  1.0  0.0  1.0  0.0  0.0  2.9  0.049 -62.955  1.698105e+09
4999  1.0  1.0  1.0  1.0  0.0  0.0  0.0  0.0  1.0  1.0  ...  1.0  1.0  1.0  0.0  0.0  1.0  2.9  0.285 -62.918  1.698111e+09

Where my data is the columns with number names. I’m using this custom dataset

class IsingDatasetFromCSV(Dataset):
    def __init__(self, csv_file, L, L2, transforms=None):
        self.path = csv_file
        self.data = np.asarray(self.path.iloc[:, :L2])
        self.labels = np.asarray(self.path.iloc[:, (L2+2)]) #L2 + 2 = E
        self.L = L  
        self.L2 = L2

        self.transforms = transforms

    def __getitem__(self, index):
        single_image_label = self.labels[index]
        # Read each L*L + T, E, M, S pixels and reshape the 1D array ([L2]) to 2D array ([L,L]) 
        img_as_np = np.asarray(self.data[index]).reshape(self.L,self.L).astype('uint8')
	    # Convert image from numpy array to PIL image, mode 'L' is for grayscale
        img_as_img = Image.fromarray(img_as_np)
        img_as_img = img_as_img.convert('L')
        
        img_as_tensor = self.transforms(img_as_np)
        
        # Return image and the label
        return (img_as_tensor, single_image_label)

    def __len__(self):
        return len(self.data)

But my data is being changed for some random numbers.

print(train_dataset[0])

(tensor([[[0.0000, 0.0039, 0.0039, 0.0000, 0.0000, 0.0000, 0.0039, 0.0000],
         [0.0000, 0.0039, 0.0039, 0.0039, 0.0000, 0.0000, 0.0000, 0.0000],
         [0.0000, 0.0039, 0.0039, 0.0039, 0.0039, 0.0039, 0.0000, 0.0000],
         [0.0039, 0.0000, 0.0000, 0.0039, 0.0000, 0.0039, 0.0039, 0.0000],
         [0.0039, 0.0039, 0.0000, 0.0000, 0.0039, 0.0039, 0.0039, 0.0039],
         [0.0039, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0039],
         [0.0039, 0.0000, 0.0000, 0.0000, 0.0000, 0.0039, 0.0000, 0.0039],
         [0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0039, 0.0000]]]), -62.949)

Does anyone know what I did wrong in the Dataset class?

It was a basic mistake, I reshape my data and defined as a different type

This:

img_as_np = np.asarray(self.data[index]).reshape(self.L,self.L).astype('uint8')

Should be this:

img_as_np = np.asarray(self.data[index]).reshape(self.L,self.L)