attention-module
attention-module copied to clipboard
How to use : training error
try
python train_imagenet.py --ngpu 4 --workers 20 --arch resnet --depth 50 --epochs 100 --batch-size 256 --lr 0.1 --att-type BAM --prefix RESNET50_IMAGENET_BAM ./data/ImageNet
showing error
(pytorch) C:\github\attention-module>python train_imagenet.py --ngpu 4 --workers 20 --arch resnet --depth 50 --epochs 100 --batch-size 256 --lr 0.1 --att-type BAM --prefix RESNET50_IMAGENET_BAM ./data/ImageNet
args Namespace(arch='resnet', att_type='BAM', batch_size=256, data='./data/ImageNet', depth=50, epochs=100, evaluate=False, lr=0.1, momentum=0.9, ngpu=4, prefix='RESNET50_IMAGENET_BAM', print_freq=10, resume='', seed=1234, start_epoch=0, weight_decay=0.0001, workers=20)
Traceback (most recent call last):
File "train_imagenet.py", line 307, in <module>
main()
File "train_imagenet.py", line 73, in main
model = ResidualNet( 'ImageNet', args.depth, 1000, args.att_type )
File "C:\github\attention-module\MODELS\model_resnet.py", line 200, in ResidualNet
model = ResNet(Bottleneck, [3, 4, 6, 3], network_type, num_classes, att_type)
File "C:\github\attention-module\MODELS\model_resnet.py", line 116, in __init__
self.bam1 = BAM(64*block.expansion)
File "C:\github\attention-module\MODELS\bam.py", line 45, in __init__
self.channel_att = ChannelGate(gate_channel)
File "C:\github\attention-module\MODELS\bam.py", line 12, in __init__
self.gate_activation = gate_activation
NameError: name 'gate_activation' is not defined
try
python train_imagenet.py --ngpu 4 --workers 20 --arch resnet --depth 50 --epochs 100 --batch-size 256 --lr 0.1 --att-type CBAM --prefix RESNET50_IMAGENET_CBAM ./data/ImageNet
showing error
(pytorch) C:\github\attention-module>python train_imagenet.py --ngpu 4 --workers 20 --arch resnet --depth 50 --epochs 100 --batch-size 256 --lr 0.1 --att-type CBAM --prefix RESNET50_IMAGENET_CBAM ./data/ImageNet
args Namespace(arch='resnet', att_type='CBAM', batch_size=256, data='./data/ImageNet', depth=50, epochs=100, evaluate=False, lr=0.1, momentum=0.9, ngpu=4, prefix='RESNET50_IMAGENET_CBAM', print_freq=10, resume='', seed=1234, start_epoch=0, weight_decay=0.0001, workers=20)
C:\github\attention-module\MODELS\model_resnet.py:129: UserWarning: nn.init.kaiming_normal is now deprecated in favor of nn.init.kaiming_normal_.
init.kaiming_normal(self.fc.weight)
C:\github\attention-module\MODELS\model_resnet.py:133: UserWarning: nn.init.kaiming_normal is now deprecated in favor of nn.init.kaiming_normal_.
init.kaiming_normal(self.state_dict()[key], mode='fan_out')
Traceback (most recent call last):
File "train_imagenet.py", line 307, in <module>
main()
File "train_imagenet.py", line 81, in main
model = torch.nn.DataParallel(model, device_ids=list(range(args.ngpu)))
File "C:\Users\admin\.conda\envs\pytorch\lib\site-packages\torch\nn\parallel\data_parallel.py", line 131, in __init__
_check_balance(self.device_ids)
File "C:\Users\admin\.conda\envs\pytorch\lib\site-packages\torch\nn\parallel\data_parallel.py", line 18, in _check_balance
dev_props = [torch.cuda.get_device_properties(i) for i in device_ids]
File "C:\Users\admin\.conda\envs\pytorch\lib\site-packages\torch\nn\parallel\data_parallel.py", line 18, in <listcomp>
dev_props = [torch.cuda.get_device_properties(i) for i in device_ids]
File "C:\Users\admin\.conda\envs\pytorch\lib\site-packages\torch\cuda\__init__.py", line 301, in get_device_properties
raise AssertionError("Invalid device id")
AssertionError: Invalid device id
What should I do?
I have met the same error
Modify the number of gpu. the default is 4 (--ngpu 4 ).
I still don't know what gate_activation should be
@ggsDing change --ngpu 4 to --ngpu 1
@hadonga Didn't get it. I was using the code directly. So 'ngpu' is relatted to 'gate_activation' ?
also meet error ‘NameError: name 'gate_activation' is not defined’,Have you solve this problem
‘self.gate_activation’ has not been used so you can delete it in bam.py, line 12
Can you see the error and how to do it: NameError: name 'size0' is not defined
Can you see the error and how to do it: NameError: name 'size0' is not defined
same question, do you know how to solve it?
You can simply remove this line 'self.gate_activation = gate_activation', as it is not used in the code :D
Can you see the error and how to do it: NameError: name 'size0' is not defined
same question, do you know how to solve it?
Same question, anybody know how to solve it?