| 121 | |
| 122 | class ResNet(nn.Module): |
| 123 | def __init__(self, block, num_blocks, n_class=10, bayesian=False): |
| 124 | super(ResNet, self).__init__() |
| 125 | # self.in_planes = 16 |
| 126 | self.embDim = 128 * block.expansion |
| 127 | # self.conv1 = nn.Conv2d(3, 16, kernel_size=3, stride=1, padding=1, bias=False) |
| 128 | # self.bn1 = nn.BatchNorm2d(16) |
| 129 | # self.layer1 = self._make_layer(block, 16, num_blocks[0], stride=1) |
| 130 | # self.layer2 = self._make_layer(block, 32, num_blocks[1], stride=2) |
| 131 | # self.layer3 = self._make_layer(block, 64, num_blocks[2], stride=2) |
| 132 | # self.layer4 = self._make_layer(block, 128, num_blocks[3], stride=2) |
| 133 | # self.linear = nn.Linear(128 * block.expansion, n_class) |
| 134 | |
| 135 | # self.dis_fc1 = nn.Linear(512, 50) |
| 136 | # self.dis_fc2 = nn.Linear(50, 1) |
| 137 | |
| 138 | self.feature_extractor = resnet_fea(block, num_blocks) |
| 139 | self.linear = resnet_clf(block, n_class) |
| 140 | self.discriminator = resnet_dis(self.embDim) |
| 141 | self.bayesian = bayesian |
| 142 | |
| 143 | # def _make_layer(self, block, planes, num_blocks, stride): |
| 144 | # strides = [stride] + [1]*(num_blocks-1) |