Hi , I am working toward creating Trin data loader in pytorch but before I need to merge the train data and the train labels, I am working on IMU data set for which the data has this shape:

Train data numpy nd array(33104,6,128,1) and the train labels numpy nd array (33104,1) how I am supposed to concatenate the labels at the last part ? since every sample of data has the shape (6,128) ?

May the IMU dataset to be used be modeled as the following?

```
import numpy as np
data = np.random.rand(33104,6,128,1)
labels = np.random.randint(0,2,(33104,1))
```

Do you have multiple datasets that should be concatenated?

1 Like

1/Yes the IMU data set can be modeled as you mentioned

2/only the train and test

Thanks

You can create a dataloader as follows:

```
>>> import torch
>>> import numpy as np
>>> data = np.random.rand(33104,6,128,1)
>>> labels = np.random.randint(0,2,(33104,1))
>>> dataset = torch.utils.data.TensorDataset(torch.from_numpy(data), torch.from_numpy(labels))
>>> loader = torch.utils.data.DataLoader(dataset, batch_size=32)
>>> for input, target in loader:
... print(input.shape, target.shape)
... break
...
torch.Size([32, 6, 128, 1]) torch.Size([32, 1])
>>> input.squeeze(3).shape
torch.Size([32, 6, 128])
>>> target.squeeze(1).shape
torch.Size([32])
```

You can drop the last dimension using torch.squeeze.

2 Likes