Niki
(Niki)
January 24, 2020, 1:05pm
#1
Hi, I want to add some zeros at the end of CIFAR-10 dataset. I tried this:

```
for batch_idx, (inputs, targets) in enumerate(trainloader):
if use_cuda:
inputs, targets = inputs.cuda(), targets.cuda()
input_zero = torch.zeros(batch_size, 3, 5, 32).cuda()
tragets_zero = torch.zeros(batch_size, 10).cuda()
targets = torch.cat((targets, tragets_zero))
inputs_new = torch.cat((inputs, input_zero), 2)
```

It shows this error at ` targets = torch.cat((targets, tragets_zero))`

:

```
RuntimeError: Expected object of scalar type Long but got scalar type Float for sequence element 1 in sequence argument at position #1 'tensors'
```

How can I solve this?

G.M
January 24, 2020, 1:33pm
#2
`torch.zeros()`

gives tensors of type `Float`

, but in this case it’s not what u want. So u should change it to Long type, like `input_zero = torch.zeros(batch_size, 3, 5, 32).long().cuda()`

or `input_zero = torch.zeros(batch_size, 3, 5, 32,dtype=torch.long,device=UR_GPU)`

.

Niki
(Niki)
January 24, 2020, 2:29pm
#3

G.M:

.long()

Thank you for your reply, @G.M . That solved the problem.

It seems there is another problem about `targets = torch.cat((targets, tragets_zero))`

:

```
RuntimeError: Tensors must have same number of dimensions: got 2 and 1 at /opt/conda/conda-bld/pytorch_.....
```

G.M
January 24, 2020, 3:02pm
#4
U should go and take a look at the doc for `torch.cat`

. Then try to print out all the shapes of the 2 tensors. Finally, u’ll realize what’s wrong

G.M
January 24, 2020, 3:05pm
#6
The issue here is quite straight forward.