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

运行ann_to_snn.py文件后,报错ValueError: ('cannot find tensor Size', torch.Size([1, 32, 416, 416])) #57

Open
Wang-jun-yu opened this issue Aug 18, 2023 · 3 comments

Comments

@Wang-jun-yu
Copy link

相同的parser在train.py文件夹下可以正常运行,但在ann_to_snn.py下报错。
我的数据集图像大小为800*800,修改下列parser为:
parser.add_argument('--img-size', nargs='+', type=int, default=[800, 800], help='[min_train, max-train, test]')
会报错ValueError: ('cannot find tensor Size', torch.Size([1, 32, 416, 416])),如果改为了default=[416, 416],依然报错:ValueError: ('cannot find tensor Size', torch.Size([1, 32, 416, 416]))
请问如何修改才能不报错?

以下为具体报错信息:

C:\Users\Lenovo.conda\envs\venv\yolov3-envs\python.exe E:\SNN\PyTorch-Spiking-YOLOv3-ultralytics\ann_to_snn.py
Namespace(augment=False, batch_size=1, cache_images=False, cfg='cfg/yolov3.cfg', channel_wise=False, conf_thres=0.001, data='data/myvoc.data', device='0', img_size=[416, 416, 416], iou_thres=0.5, multi_scale=False, rect=False, reset_mode='subtraction', save_file='yolov3-my-snn', save_json=False, single_cls=False, statistics_iters=30, task='test', timesteps=100, weights='weights/best.pt')
Using CUDA device0 _CudaDeviceProperties(name='NVIDIA GeForce RTX 3060 Laptop GPU', total_memory=6143MB)

Caching labels E:\DataSate\labels\train.npy (5043 found, 0 missing, 0 empty, 0 duplicate, for 5043 images): 100%|██████████| 5043/5043 [00:00<00:00, 19846.45it/s]
Model Summary: 222 layers, 6.15237e+07 parameters, 6.15237e+07 gradients
add node conv1: ['dag_input0']->['conv1_out1']
Traceback (most recent call last):
File "E:\SNN\PyTorch-Spiking-YOLOv3-ultralytics\ann_to_snn.py", line 182, in
transformer.inference_get_status(dataloader, opt.statistics_iters)
File "E:\SNN\PyTorch-Spiking-YOLOv3-ultralytics\spiking_utils\snn_transformer.py", line 94, in inference_get_status
self.init_dag([data])
File "E:\SNN\PyTorch-Spiking-YOLOv3-ultralytics\spiking_utils\snn_transformer.py", line 69, in init_dag
self.snn_dag = ann_parser.parse_ann_model(self.original_net, inputs)
File "E:\SNN\PyTorch-Spiking-YOLOv3-ultralytics\spiking_utils\ann_parser.py", line 221, in parse_ann_model
model(*warpped_input)
File "C:\Users\Lenovo.conda\envs\venv\yolov3-envs\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "E:\SNN\PyTorch-Spiking-YOLOv3-ultralytics\ann_to_snn.py", line 65, in forward
x = self.listi
File "C:\Users\Lenovo.conda\envs\venv\yolov3-envs\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "C:\Users\Lenovo.conda\envs\venv\yolov3-envs\lib\site-packages\torch\nn\modules\container.py", line 117, in forward
input = module(input)
File "C:\Users\Lenovo.conda\envs\venv\yolov3-envs\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "C:\Users\Lenovo.conda\envs\venv\yolov3-envs\lib\site-packages\torch\nn\modules\conv.py", line 423, in forward
return self._conv_forward(input, self.weight)
File "C:\Users\Lenovo.conda\envs\venv\yolov3-envs\lib\site-packages\torch\nn\modules\conv.py", line 420, in _conv_forward
self.padding, self.dilation, self.groups)
File "E:\SNN\PyTorch-Spiking-YOLOv3-ultralytics\spiking_utils\ann_parser.py", line 69, in conv2d_wrapper
in_nodes = [find_node_by_tensor(inp)]
File "E:\SNN\PyTorch-Spiking-YOLOv3-ultralytics\spiking_utils\ann_parser.py", line 10, in find_node_by_tensor
raise ValueError("cannot find tensor Size", tensor.size())
ValueError: ('cannot find tensor Size', torch.Size([1, 32, 416, 416]))

Process finished with exit code 1

@sun133233
Copy link

同样遇到这个问题,请问你解决了吗

@jsckdon
Copy link

jsckdon commented Apr 25, 2024

@sun133233 请问您解决了吗

@Shenyiyu1
Copy link

@sun133233 请问您解决了吗

请问你们跑通这个代码了码,为啥我用gpu训练的时候,老显示2个设备报错
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

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

4 participants