I am trying to debug and watch the values of a code for studying machine learning. Here’s the code snippet:
train_data = DataGenerator(lines[:num_train], input_shape, True) # num_train is 1066
......
gen_train = DataLoader(train_data, batch_size=4)
......
epochs = 20
for epoch in range(epochs):
total_train = 0
for data in gen_train:
img, label = data # breakpoint here
with torch.no_grad():
img = img.to(device)
label = label.to(device)
optim.zero_grad()
output = net(img)
train_loss = nn.CrossEntropyLoss()(output, label).to(device)
train_loss.backward()
optim.step()
total_train += train_loss
......
here in this code, img are 4 images loaded, and label are 4 integers that corresponds to the images’ class. when I put a breakpoint, I saw the images has 4 “blocks”, each block has all same values:
(as I am new user, I can only upload one image, but all other 3 blocks has the same value)
these blocks should be the images, but why they all have the same numbers?