Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a column of data #71

Closed
xuV2 opened this issue Jul 11, 2022 · 11 comments
Closed

Add a column of data #71

xuV2 opened this issue Jul 11, 2022 · 11 comments

Comments

@xuV2
Copy link

xuV2 commented Jul 11, 2022

Hello! @pangsu0613 I read your paper(Fast-CLOCs), and I also added a column of data to your code, changing it from 1p4 to 1p5, but there is an error in my code( self.opt.step() in fastai_optim.py).RuntimeError: The size of tensor a (4) must match the size of tensor b (5) at non-singleton dimension 1.

@pangsu0613
Copy link
Owner

Hello @xuV2 . If one needs to add more channels (or modify the number of channels), these places below need to be modified:
(1)you also need to modify the build_stage2_training function below, add another colum in variable "overlaps".

def build_stage2_training(boxes, query_boxes, criterion, scores_3d, scores_2d, dis_to_lidar_3d,overlaps,tensor_index):

(2)change the hardcoded "4" channels into "5", from line 521-527 (or other number of channels if you want):
overlaps1 = np.zeros((900000,4),dtype=box_2d_preds.detach().cpu().numpy().dtype)

(3)change the hardcoded "4" into "5" in CLOCs model:
nn.Conv2d(4,18,1),

My apology to hardcoded these information. I'll update the repo later to remove these hardcoded value.

@xuV2
Copy link
Author

xuV2 commented Jul 12, 2022

Hello! @pangsu0613 First of all, thank you for your prompt reply. But I have changed the code you mentioned, but when the code runs to train.py(line 279) during training, it will still make mistakes.When I delete 279 lines, the code can be trained.
CLOCs/blob/master/second/pytorch/train.py
279 mixed_optimizer.step()

@xuV2
Copy link
Author

xuV2 commented Jul 12, 2022

The reason for the error is
RuntimeError: The size of tensor a (4) must match the size of tensor b (5) at non-singleton dimension 1

@pangsu0613
Copy link
Owner

mixed_optimizer.step() should not be deleted. Could you show me the whole error message?

@xuV2
Copy link
Author

xuV2 commented Jul 12, 2022

Traceback (most recent call last):
File "./pytorch/train.py", line 985, in
fire.Fire()
File "/root/anaconda3/envs/CLOCs/lib/python3.6/site-packages/fire/core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/root/anaconda3/envs/CLOCs/lib/python3.6/site-packages/fire/core.py", line 471, in Fire
target=component.name)
File "/root/anaconda3/envs/CLOCs/lib/python3.6/site-packages/fire/core.py", line 681, in CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "./pytorch/train.py", line 431, in train
raise e
File "./pytorch/train.py", line 336, in train
mixed_optimizer.step() # 这句话有问题 # 通过梯度下降更新参数
File "/root/CLOCs/torchplus/train/fastai_optim.py", line 136, in step
self.opt.step() # 有问题
File "/root/anaconda3/envs/CLOCs/lib/python3.6/site-packages/torch/optim/adam.py", line 93, in step
exp_avg.mul
(beta1).add
(1 - beta1, grad)
RuntimeError: The size of tensor a (4) must match the size of tensor b (5) at non-singleton dimension 1

@pangsu0613
Copy link
Owner

did you change the "4" at line 521 and line 524 in voxelnet.py?

@xuV2
Copy link
Author

xuV2 commented Jul 12, 2022

iou_test_tensor = iou_test_tensor.reshape(1, 5, 1, 900000) # 原来是4
# print(iou_test_tensor.shape) (1, 5, 1, 900000)
tensor_index_tensor = tensor_index_tensor.reshape(-1, 2)
if max_num == 0:
non_empty_iou_test_tensor = torch.zeros(1, 5, 1, 2)
non_empty_iou_test_tensor[:, :, :, :] = -1
non_empty_tensor_index_tensor = torch.zeros(2, 2)
non_empty_tensor_index_tensor[:, :] = -1
else:
non_empty_iou_test_tensor = iou_test_tensor[:, :, :, :max_num]
# print(non_empty_iou_test_tensor.shape) # torch.Size([1, 5, 1, 313987])
non_empty_tensor_index_tensor = tensor_index_tensor[:max_num, :]

@pangsu0613
Copy link
Owner

could you delete all the files in the working directory (including the adam_optimizer-xxxx.tckpt and other files)?

@xuV2
Copy link
Author

xuV2 commented Jul 12, 2022

I'm sorry I don't have this ability. I'm just a novice.😭

@pangsu0613
Copy link
Owner

when you run training in the terminal:
python ./pytorch/train.py train --config_path=./configs/car.fhd.config --model_dir=/dir/to/your_model_dir
you create a model directory (--model_dir=/dir/to/your_model_dir), just delete everything in that directory.

@xuV2
Copy link
Author

xuV2 commented Jul 12, 2022

感谢您的建议,我已经成功解决了我的问题,真的非常感谢您的建议!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants