When downloading and exploring the tensor created from the following dataset ('http://codh.rois.ac.jp/kmnist/dataset/kmnist/kmnist-train-imgs.npz') there doesn't appear to be a grayscale element to the tensor. How can I see this and then manipulate the tensor so the grayscale figure (1) is at the end of the tensor. The current shape of the tensor is (60000, 28, 28).
We have created the function to load the data into a variable:
def load(f):
return np.load(f)\['arr_0'\]
The Data is then loaded in using the following code:
x_train = load('kmnist-train-imgs.npz') ## file name after it was downloaded to a local folder
This was transformed into a tensor with
torch.tensor(x_train)
x_train.shape
returns: torch.Size([60000, 28, 28])
We've been asked to reshape the data - the final dimensions, in order, should be: (row_number, height, width, channel)
The question...
is 60000 in torch.Size([60000, 28, 28]) the Channel or the row number? we are not sure what we need to add to the Tensor - if anything. We know we can access the Data in with x_train[I] so my assumption is that it is the "row_number".
Depending on the outcome above we have the following experimental code for reshaping purposes:
print(np.shape(x_train))
data = np.moveaxis(x_train,0, -1)
print(np.shape(data))
This returns:
(60000, 28, 28)
(28, 28, 60000)
As part of investigations we have run the following code (taken from Pytorch documentation):
torchvision.transforms.functional.get_image_num_channels(x_train[1])
This returns: 1. This tells us there is one channel associated with the Data set...stumped on how to view the channel and the value in it.
Any help would be appreciated.