This is a PyTorch implementation of the paper "Multi-branch and Multi-scale Attention Learning for Fine-Grained Visual Categorization (MMAL-Net)" (Fan Zhang, Meng Li, Guisheng Zhai, Yizhao Liu).
您好,我在运行训练时遇到一个问题,源代码如下
properties = measure.regionprops(component_labels)
areas = []
for prop in properties:
areas.append(prop.area)
max_idx = areas.index(max(areas))
报错内容为
ValueError: max() arg is an empty sequence
它显示max()中的areas为空,无法读取
我想询问是少了什么吗?
请问这个问题你解决了吗?我把这个模块加进我的模型以后,一开始在双卡上回报这个错误,但移到单卡上也会发生这个问题。但奇怪的是相同的batch-size有时候就可以畅通无阻的训练,有的时候就会出现这个错误。
Traceback (most recent call last):
File "train.py", line 33, in
do_train(
File "/root/autodl-tmp/PART-master/processor/processor.py", line 102, in do_train
cls_g, cls_1 = model(img, target,mode='train') #0515
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, kwargs)
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 168, in forward
outputs = self.parallel_apply(replicas, inputs, kwargs)
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 178, in parallel_apply
return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)])
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/parallel/parallel_apply.py", line 86, in parallel_apply
output.reraise()
File "/root/miniconda3/lib/python3.8/site-packages/torch/_utils.py", line 425, in reraise
raise self.exc_type(msg)
ValueError: Caught ValueError in replica 0 on device 0.
Original Traceback (most recent call last):
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/parallel/parallel_apply.py", line 61, in _worker
output = module(*input, *kwargs)
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(input, kwargs)
File "/root/autodl-tmp/PART-master/model/make_model.py", line 321, in forward
return self.forward_multi(inputs, label)
File "/root/autodl-tmp/PART-master/model/make_model.py", line 406, in forward_multi
coordinates = torch.tensor(AOLM(out.detach()))
File "/root/autodl-tmp/PART-master/model/make_model.py", line 33, in AOLM
max_idx = areas.index(max(areas))
ValueError: max() arg is an empty sequence
您好,我在运行训练时遇到一个问题,源代码如下 properties = measure.regionprops(component_labels) areas = [] for prop in properties: areas.append(prop.area) max_idx = areas.index(max(areas)) 报错内容为 ValueError: max() arg is an empty sequence 它显示max()中的areas为空,无法读取 我想询问是少了什么吗?