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

After running python train_OAAT.py --use_defaults CIFAR100_WRN error BasicBlock #1

Open
headscott opened this issue Jul 27, 2024 · 0 comments

Comments

@headscott
Copy link

I got this error after the training finished:

File "OAAT/perceptual_advex/perceptual_attack_adv.py", line 65, in _make_layer
    layers.append(block(i == 0 and in_planes or out_planes, out_planes, i == 0 and stride or 1, dropRate))
TypeError: BasicBlock.__init__() takes from 3 to 4 positional arguments but 5 were given

And I think the problem is, that there are two definitions von BasicBlock in perceptual_attack_adv.py:
The one for WideResNet:

class BasicBlock(nn.Module):
    def __init__(self, in_planes, out_planes, stride, dropRate=0.0):
        super(BasicBlock, self).__init__()
        self.bn1 = nn.BatchNorm2d(in_planes)
        self.relu1 = nn.ReLU(inplace=True)
        ...

The one for ResNet:

class BasicBlock(nn.Module):
    expansion = 1

    def __init__(self, in_planes, planes, stride=1):
        super(BasicBlock, self).__init__()
        self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=3, stride=stride, padding=1, bias=False)
        ...

This should be fixed by renaming one or both of them to something like WideResBasicBlock or ResBasicBlock. I'll try it myself now, and then I will tell my result.

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

1 participant