I’m trying to train a CNN that uses a set of .npy files that describes images. I load my files using DatasetFolder for label my files with the name of the subdirectories, similar to the training that uses Cat vs Dogs, but with astronomical images.
def npy_loader(path):
sample = torch.from_numpy(np.load(path))
return sample
#np.load(os.path.join(self.directory, fname)) np.load(path)
train_ds = datasets.DatasetFolder(
root='/content/NPYTrainData_S1617_S1618',
loader=npy_loader,
extensions=('.npy')
)
test_ds = datasets.DatasetFolder(
root='/content/NPYTestData_17185',
loader=npy_loader,
extensions=('.npy')
)```
When trying to use a similar training loop like in the PyTorch documentation, the given error is this:
ValueError: given numpy array has byte order different from the native byte order. Conversion between byte orders is currently not supported.
The loop is this:
for epoch in range(2): # loop over the dataset multiple times
running_loss = 0.0
for i, data in enumerate(train_loader, 0):
# get the inputs; data is a list of [inputs, labels]
inputs, labels = data
# zero the parameter gradients
optimizer.zero_grad()
# forward + backward + optimize
outputs = net(inputs)
loss = criterion(outputs, labels)
loss.backward()
optimizer.step()
# print statistics
running_loss += loss.item()
if i % 2000 == 1999: # print every 2000 mini-batches
print('[%d, %5d] loss: %.3f' %
(epoch + 1, i + 1, running_loss / 2000))
running_loss = 0.0
print(‘Finished Training’)
I'm barely new with all this stuff of programming and don't know what's going on. Any advice would be appreciated!