Closed ThuSNO3 closed 4 years ago
I used CBAM code from https://github.com/Jongchan/attention-module/tree/master/MODELS I think the code in the repo might need to be
class Bottleneck(nn.Module):
expansion = 4
for larger ResNets to work. Let me know if that works.
Thank you for sharing your work. I have two questions.
First, I found a undefined class as 'BAM' and undefined type as 'BAM' in the line 118-121 at the \models\cbam\model_resnet.py. Do you mean 'CBAM' here?
Second, when I tried to train one-class-ood on ResidualNet with depth of 18 and 34, which used the BasicBlock defined in your code, the model run fine. However when using ResidualNet with depth of 50 and 101, based on the Bottleneck, the model seemed to have some problem. The size of "out" and "residual" in the line 96 at \models\cbam\model_resnet.py is not the same shape. Here is the Traceback: Traceback (most recent call last): 7 File "train.py", line 224, in
8 train()
9 File "train.py", line 164, in train
10 x = net(2 data - 1)
11 File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in call
12 result = self.forward(input, kwargs)
13 File "/data/workplace/ss-ood-master/models/cbam/model_resnet.py", line 169, in forward
14 x = self.layer1(x)
15 File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in call
16 result = self.forward(*input, *kwargs)
17 File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/container.py", line 92, in forward
18 input = module(input)
19 File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in call
20 result = self.forward(input, kwargs)
21 File "/data/workplace/ss-ood-master/models/cbam/model_resnet.py", line 96, in forward
22 out += residual
23 RuntimeError: The size of tensor a (256) must match the size of tensor b (64) at non-singleton dimension 1