skyhehe123/VoxelNet-pytorch

shape mismatch: value tensor of shape [31564, 128] cannot be broadcast to indexing result of shape [128, 31564]

Yi-Shi94 opened this issue · 2 comments

My working environment:
Pytorch 1.0
Mac OS

This error happens when I tried to run training.
Full error message:
Traceback (most recent call last):
File "train.py", line 126, in
train()
File "train.py", line 102, in train
psm,rm = net(voxel_features, voxel_coords)
File "/home/screentest/anaconda3/envs/screentest/lib/python3.7/site-packages/torch/nn/modules/module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "/home/screentest/ys3237/backup/VoxelNet-pytorch/voxelnet.py", line 171, in forward
vwfs = self.voxel_indexing(vwfs,voxel_coords)
File "/home/screentest/ys3237/backup/VoxelNet-pytorch/voxelnet.py", line 163, in voxel_indexing
dense_feature[:, coords[:,0], coords[:,1], coords[:,2], coords[:,3]]= sparse_features
RuntimeError: shape mismatch: value tensor of shape [31564, 128] cannot be broadcast to indexing result of shape [128, 31564]

If I change
dense_feature[:, coords[:,0], coords[:,1], coords[:,2], coords[:,3]]= sparse_features
Into
dense_feature[:,coords[:,0],coords[:,1],coords[:,2],coords[:,3]]= \ sparse_features.transpose(0,1)
The problem is then solved.

Btw, if you use Pytorch 1.0, you should also change loss[0] into loss.item().