Python torch.nn.Conv2d() Examples
The following are 30
code examples of torch.nn.Conv2d().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
torch.nn
, or try the search function
.
Example #1
Source File: model.py From cat-bbs with MIT License | 9 votes |
def __init__(self): super(Model2, self).__init__() # fine tuning the ResNet helped significantly with the accuracy base_model = MyResNet(BasicBlock, [2, 2, 2, 2]) base_model.load_state_dict(model_zoo.load_url(model_urls['resnet18'])) # code needed to deactivate fine tuning of resnet #for param in base_model.parameters(): # param.requires_grad = False self.base_model = base_model self.drop0 = nn.Dropout2d(0.05) self.conv1 = nn.Conv2d(512, 256, 3, padding=1, bias=False) self.bn1 = nn.BatchNorm2d(256) self.drop1 = nn.Dropout2d(0.05) self.conv2 = nn.Conv2d(256, 128, 3, padding=1, bias=False) self.bn2 = nn.BatchNorm2d(128) self.drop2 = nn.Dropout2d(0.05) self.conv3 = nn.Conv2d(128, 1+9, 3, padding=1, bias=False)
Example #2
Source File: model.py From cat-bbs with MIT License | 8 votes |
def __init__(self, block, layers, num_classes=1000): self.inplanes = 64 super(MyResNet, self).__init__() self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3, bias=False) self.bn1 = nn.BatchNorm2d(64) self.relu = nn.ReLU(inplace=True) self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1) # note the increasing dilation self.layer1 = self._make_layer(block, 64, layers[0]) self.layer2 = self._make_layer(block, 128, layers[1], stride=2, dilation=1) self.layer3 = self._make_layer(block, 256, layers[2], stride=1, dilation=2) self.layer4 = self._make_layer(block, 512, layers[3], stride=1, dilation=4) # these layers will not be used self.avgpool = nn.AvgPool2d(7) self.fc = nn.Linear(512 * block.expansion, num_classes) for m in self.modules(): if isinstance(m, nn.Conv2d): n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels m.weight.data.normal_(0, math.sqrt(2. / n)) elif isinstance(m, nn.BatchNorm2d): m.weight.data.fill_(1) m.bias.data.zero_()
Example #3
Source File: rfp.py From mmdetection with Apache License 2.0 | 7 votes |
def __init__(self, in_channels, out_channels, dilations=(1, 3, 6, 1)): super().__init__() assert dilations[-1] == 1 self.aspp = nn.ModuleList() for dilation in dilations: kernel_size = 3 if dilation > 1 else 1 padding = dilation if dilation > 1 else 0 conv = nn.Conv2d( in_channels, out_channels, kernel_size=kernel_size, stride=1, dilation=dilation, padding=padding, bias=True) self.aspp.append(conv) self.gap = nn.AdaptiveAvgPool2d(1) self.init_weights()
Example #4
Source File: resnet_v1.py From Collaborative-Learning-for-Weakly-Supervised-Object-Detection with MIT License | 7 votes |
def __init__(self, block, layers, num_classes=1000): self.inplanes = 64 super(ResNet, self).__init__() self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3, bias=False) self.bn1 = nn.BatchNorm2d(64) self.relu = nn.ReLU(inplace=True) # maxpool different from pytorch-resnet, to match tf-faster-rcnn self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1) self.layer1 = self._make_layer(block, 64, layers[0]) self.layer2 = self._make_layer(block, 128, layers[1], stride=2) self.layer3 = self._make_layer(block, 256, layers[2], stride=2) # use stride 1 for the last conv4 layer (same as tf-faster-rcnn) self.layer4 = self._make_layer(block, 512, layers[3], stride=1) for m in self.modules(): if isinstance(m, nn.Conv2d): n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels m.weight.data.normal_(0, math.sqrt(2. / n)) elif isinstance(m, nn.BatchNorm2d): m.weight.data.fill_(1) m.bias.data.zero_()
Example #5
Source File: resnext.py From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self, in_planes, cardinality=32, bottleneck_width=4, stride=1): super(Block, self).__init__() group_width = cardinality * bottleneck_width self.conv1 = nn.Conv2d(in_planes, group_width, kernel_size=1, bias=False) self.bn1 = nn.BatchNorm2d(group_width) self.conv2 = nn.Conv2d(group_width, group_width, kernel_size=3, stride=stride, padding=1, groups=cardinality, bias=False) self.bn2 = nn.BatchNorm2d(group_width) self.conv3 = nn.Conv2d(group_width, self.expansion*group_width, kernel_size=1, bias=False) self.bn3 = nn.BatchNorm2d(self.expansion*group_width) self.shortcut = nn.Sequential() if stride != 1 or in_planes != self.expansion*group_width: self.shortcut = nn.Sequential( nn.Conv2d(in_planes, self.expansion*group_width, kernel_size=1, stride=stride, bias=False), nn.BatchNorm2d(self.expansion*group_width) )
Example #6
Source File: network.py From Collaborative-Learning-for-Weakly-Supervised-Object-Detection with MIT License | 6 votes |
def _init_modules(self): self._init_head_tail() # rpn self.rpn_net = nn.Conv2d(self._net_conv_channels, cfg.RPN_CHANNELS, [3, 3], padding=1) self.rpn_cls_score_net = nn.Conv2d(cfg.RPN_CHANNELS, self._num_anchors * 2, [1, 1]) self.rpn_bbox_pred_net = nn.Conv2d(cfg.RPN_CHANNELS, self._num_anchors * 4, [1, 1]) self.cls_score_net_fast = nn.Linear(self._fc7_channels, self._num_classes+1) self.bbox_pred_net_fast = nn.Linear(self._fc7_channels, (self._num_classes+1) * 4) self.cls_score_net = nn.Linear(self._fc7_channels, self._num_classes) # between class self.bbox_pred_net = nn.Linear(self._fc7_channels, self._num_classes) # between boxes self.init_weights()
Example #7
Source File: model.py From cat-bbs with MIT License | 6 votes |
def _make_layer(self, block, planes, blocks, stride=1, dilation=1): downsample = None if stride != 1 or self.inplanes != planes * block.expansion: downsample = nn.Sequential( nn.Conv2d(self.inplanes, planes * block.expansion, kernel_size=1, stride=stride, bias=False), nn.BatchNorm2d(planes * block.expansion), ) layers = [] layers.append(block(self.inplanes, planes, stride, 1, downsample)) self.inplanes = planes * block.expansion for i in range(1, blocks): # here with dilation layers.append(block(self.inplanes, planes, dilation=dilation)) return nn.Sequential(*layers)
Example #8
Source File: resnet_v1.py From Collaborative-Learning-for-Weakly-Supervised-Object-Detection with MIT License | 6 votes |
def _make_layer(self, block, planes, blocks, stride=1): downsample = None if stride != 1 or self.inplanes != planes * block.expansion: downsample = nn.Sequential( nn.Conv2d(self.inplanes, planes * block.expansion, kernel_size=1, stride=stride, bias=False), nn.BatchNorm2d(planes * block.expansion), ) layers = [] layers.append(block(self.inplanes, planes, stride, downsample)) self.inplanes = planes * block.expansion for i in range(1, blocks): layers.append(block(self.inplanes, planes)) return nn.Sequential(*layers)
Example #9
Source File: model.py From cat-bbs with MIT License | 6 votes |
def __init__(self): super(Model, self).__init__() self.conv1 = nn.Conv2d(3, 16, 3, padding=1) self.bn1 = nn.BatchNorm2d(16) self.conv2 = nn.Conv2d(16, 32, 3, padding=1) self.bn2 = nn.BatchNorm2d(32) self.conv3 = nn.Conv2d(32, 64, 3, padding=1) self.bn3 = nn.BatchNorm2d(64) self.conv4 = nn.Conv2d(64, 128, 3, padding=1) self.bn4 = nn.BatchNorm2d(128) self.conv5 = nn.Conv2d(128, 128, 3, dilation=2, padding=2) self.bn5 = nn.BatchNorm2d(128) self.conv6 = nn.Conv2d(128, 128, 3, dilation=4, padding=4) self.bn6 = nn.BatchNorm2d(128) self.conv7 = nn.Conv2d(128, 1+9, 3, padding=1)
Example #10
Source File: hrnet.py From mmdetection with Apache License 2.0 | 6 votes |
def init_weights(self, pretrained=None): """Initialize the weights in backbone. Args: pretrained (str, optional): Path to pre-trained weights. Defaults to None. """ if isinstance(pretrained, str): logger = get_root_logger() load_checkpoint(self, pretrained, strict=False, logger=logger) elif pretrained is None: for m in self.modules(): if isinstance(m, nn.Conv2d): kaiming_init(m) elif isinstance(m, (_BatchNorm, nn.GroupNorm)): constant_init(m, 1) if self.zero_init_residual: for m in self.modules(): if isinstance(m, Bottleneck): constant_init(m.norm3, 0) elif isinstance(m, BasicBlock): constant_init(m.norm2, 0) else: raise TypeError('pretrained must be a str or None')
Example #11
Source File: res_layer.py From mmdetection with Apache License 2.0 | 6 votes |
def init_weights(self, pretrained=None): """Initialize the weights in the module. Args: pretrained (str, optional): Path to pre-trained weights. Defaults to None. """ if isinstance(pretrained, str): logger = get_root_logger() load_checkpoint(self, pretrained, strict=False, logger=logger) elif pretrained is None: for m in self.modules(): if isinstance(m, nn.Conv2d): kaiming_init(m) elif isinstance(m, nn.BatchNorm2d): constant_init(m, 1) else: raise TypeError('pretrained must be a str or None')
Example #12
Source File: rfp.py From mmdetection with Apache License 2.0 | 6 votes |
def __init__(self, rfp_steps, rfp_backbone, aspp_out_channels, aspp_dilations=(1, 3, 6, 1), **kwargs): super().__init__(**kwargs) self.rfp_steps = rfp_steps self.rfp_modules = nn.ModuleList() for rfp_idx in range(1, rfp_steps): rfp_module = build_backbone(rfp_backbone) self.rfp_modules.append(rfp_module) self.rfp_aspp = ASPP(self.out_channels, aspp_out_channels, aspp_dilations) self.rfp_weight = nn.Conv2d( self.out_channels, 1, kernel_size=1, stride=1, padding=0, bias=True)
Example #13
Source File: fovea_head.py From mmdetection with Apache License 2.0 | 6 votes |
def __init__(self, in_channels, out_channels, kernel_size=3, deformable_groups=4): super(FeatureAlign, self).__init__() offset_channels = kernel_size * kernel_size * 2 self.conv_offset = nn.Conv2d( 4, deformable_groups * offset_channels, 1, bias=False) self.conv_adaption = DeformConv( in_channels, out_channels, kernel_size=kernel_size, padding=(kernel_size - 1) // 2, deformable_groups=deformable_groups) self.relu = nn.ReLU(inplace=True)
Example #14
Source File: model.py From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self): super(CW2_Net, self).__init__() self.conv1 = nn.Conv2d(3, 32, 3) self.bnm1 = nn.BatchNorm2d(32, momentum=0.1) self.conv2 = nn.Conv2d(32, 64, 3) self.bnm2 = nn.BatchNorm2d(64, momentum=0.1) self.conv3 = nn.Conv2d(64, 128, 3) self.bnm3 = nn.BatchNorm2d(128, momentum=0.1) self.conv4 = nn.Conv2d(128, 128, 3) self.bnm4 = nn.BatchNorm2d(128, momentum=0.1) self.fc1 = nn.Linear(3200, 256) #self.dropout1 = nn.Dropout(p=0.35, inplace=False) self.bnm5 = nn.BatchNorm1d(256, momentum=0.1) self.fc2 = nn.Linear(256, 256) self.bnm6 = nn.BatchNorm1d(256, momentum=0.1) self.fc3 = nn.Linear(256, 10) #self.dropout2 = nn.Dropout(p=0.35, inplace=False) #self.dropout3 = nn.Dropout(p=0.35, inplace=False)
Example #15
Source File: guided_anchor_head.py From mmdetection with Apache License 2.0 | 6 votes |
def __init__(self, in_channels, out_channels, kernel_size=3, deformable_groups=4): super(FeatureAdaption, self).__init__() offset_channels = kernel_size * kernel_size * 2 self.conv_offset = nn.Conv2d( 2, deformable_groups * offset_channels, 1, bias=False) self.conv_adaption = DeformConv( in_channels, out_channels, kernel_size=kernel_size, padding=(kernel_size - 1) // 2, deformable_groups=deformable_groups) self.relu = nn.ReLU(inplace=True)
Example #16
Source File: senet.py From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License | 6 votes |
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) self.bn1 = nn.BatchNorm2d(planes) self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=1, padding=1, bias=False) self.bn2 = nn.BatchNorm2d(planes) self.shortcut = nn.Sequential() if stride != 1 or in_planes != planes: self.shortcut = nn.Sequential( nn.Conv2d(in_planes, planes, kernel_size=1, stride=stride, bias=False), nn.BatchNorm2d(planes) ) # SE layers self.fc1 = nn.Conv2d(planes, planes//16, kernel_size=1) # Use nn.Conv2d instead of nn.Linear self.fc2 = nn.Conv2d(planes//16, planes, kernel_size=1)
Example #17
Source File: dpn.py From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self, last_planes, in_planes, out_planes, dense_depth, stride, first_layer): super(Bottleneck, self).__init__() self.out_planes = out_planes self.dense_depth = dense_depth self.conv1 = nn.Conv2d(last_planes, in_planes, kernel_size=1, bias=False) self.bn1 = nn.BatchNorm2d(in_planes) self.conv2 = nn.Conv2d(in_planes, in_planes, kernel_size=3, stride=stride, padding=1, groups=32, bias=False) self.bn2 = nn.BatchNorm2d(in_planes) self.conv3 = nn.Conv2d(in_planes, out_planes+dense_depth, kernel_size=1, bias=False) self.bn3 = nn.BatchNorm2d(out_planes+dense_depth) self.shortcut = nn.Sequential() if first_layer: self.shortcut = nn.Sequential( nn.Conv2d(last_planes, out_planes+dense_depth, kernel_size=1, stride=stride, bias=False), nn.BatchNorm2d(out_planes+dense_depth) )
Example #18
Source File: model.py From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self): super(Net, self).__init__() self.conv1 = nn.Conv2d(3, 10, kernel_size=5) self.conv2 = nn.Conv2d(10, 20, kernel_size=5) self.conv2_drop = nn.Dropout2d() self.fc1 = nn.Linear(320, 50) self.fc2 = nn.Linear(50, 10)
Example #19
Source File: small_model.py From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self): super(Net, self).__init__() self.conv1 = nn.Conv2d(1, 10, kernel_size=3, stride=2) self.conv2 = nn.Conv2d(10, 10, kernel_size=3, stride=2) #self.conv3 = nn.Conv2d(10, 10, kernel_size=3, stride=1) #self.drop = nn.Dropout2d() # self.fc1 = nn.Linear(784, 200) self.fc1 = nn.Linear(360, 200) self.fc2 = nn.Linear(200, 10)
Example #20
Source File: test_wrappers.py From mmdetection with Apache License 2.0 | 5 votes |
def test_conv2d(): """ CommandLine: xdoctest -m tests/test_wrappers.py test_conv2d """ test_cases = OrderedDict([('in_w', [10, 20]), ('in_h', [10, 20]), ('in_channel', [1, 3]), ('out_channel', [1, 3]), ('kernel_size', [3, 5]), ('stride', [1, 2]), ('padding', [0, 1]), ('dilation', [1, 2])]) # train mode for in_h, in_w, in_cha, out_cha, k, s, p, d in product( *list(test_cases.values())): # wrapper op with 0-dim input x_empty = torch.randn(0, in_cha, in_h, in_w) torch.manual_seed(0) wrapper = Conv2d(in_cha, out_cha, k, stride=s, padding=p, dilation=d) wrapper_out = wrapper(x_empty) # torch op with 3-dim input as shape reference x_normal = torch.randn(3, in_cha, in_h, in_w).requires_grad_(True) torch.manual_seed(0) ref = nn.Conv2d(in_cha, out_cha, k, stride=s, padding=p, dilation=d) ref_out = ref(x_normal) assert wrapper_out.shape[0] == 0 assert wrapper_out.shape[1:] == ref_out.shape[1:] wrapper_out.sum().backward() assert wrapper.weight.grad is not None assert wrapper.weight.grad.shape == wrapper.weight.shape assert torch.equal(wrapper(x_normal), ref_out) # eval mode x_empty = torch.randn(0, in_cha, in_h, in_w) wrapper = Conv2d(in_cha, out_cha, k, stride=s, padding=p, dilation=d) wrapper.eval() wrapper(x_empty)
Example #21
Source File: small_model.py From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self): super(Very_Small_Net, self).__init__() #self.conv1 = nn.Conv2d(1, 10, kernel_size=3, stride=2) #self.conv2 = nn.Conv2d(10, 10, kernel_size=3, stride=2) #self.conv3 = nn.Conv2d(10, 10, kernel_size=3, stride=1) #self.drop = nn.Dropout2d() # self.fc1 = nn.Linear(784, 200) self.fc1 = nn.Linear(784, 200) self.fc2 = nn.Linear(200, 10)
Example #22
Source File: deform_conv.py From mmdetection with Apache License 2.0 | 5 votes |
def __init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, deformable_groups=1, bias=True): super(ModulatedDeformConv, self).__init__() self.in_channels = in_channels self.out_channels = out_channels self.kernel_size = _pair(kernel_size) self.stride = stride self.padding = padding self.dilation = dilation self.groups = groups self.deformable_groups = deformable_groups self.with_bias = bias # enable compatibility with nn.Conv2d self.transposed = False self.output_padding = _single(0) self.weight = nn.Parameter( torch.Tensor(out_channels, in_channels // groups, *self.kernel_size)) if bias: self.bias = nn.Parameter(torch.Tensor(out_channels)) else: self.register_parameter('bias', None) self.init_weights()
Example #23
Source File: fuse_conv_bn.py From mmdetection with Apache License 2.0 | 5 votes |
def fuse_module(m): last_conv = None last_conv_name = None for name, child in m.named_children(): if isinstance(child, (nn.BatchNorm2d, nn.SyncBatchNorm)): if last_conv is None: # only fuse BN that is after Conv continue fused_conv = fuse_conv_bn(last_conv, child) m._modules[last_conv_name] = fused_conv # To reduce changes, set BN as Identity instead of deleting it. m._modules[name] = nn.Identity() last_conv = None elif isinstance(child, nn.Conv2d): last_conv = child last_conv_name = name else: fuse_module(child) return m
Example #24
Source File: deform_conv.py From mmdetection with Apache License 2.0 | 5 votes |
def __init__(self, *args, **kwargs): super(ModulatedDeformConvPack, self).__init__(*args, **kwargs) self.conv_offset = nn.Conv2d( self.in_channels, self.deformable_groups * 3 * self.kernel_size[0] * self.kernel_size[1], kernel_size=self.kernel_size, stride=_pair(self.stride), padding=_pair(self.padding), dilation=_pair(self.dilation), bias=True) self.init_weights()
Example #25
Source File: deform_conv.py From mmdetection with Apache License 2.0 | 5 votes |
def __init__(self, *args, **kwargs): super(DeformConvPack, self).__init__(*args, **kwargs) self.conv_offset = nn.Conv2d( self.in_channels, self.deformable_groups * 2 * self.kernel_size[0] * self.kernel_size[1], kernel_size=self.kernel_size, stride=_pair(self.stride), padding=_pair(self.padding), dilation=_pair(self.dilation), bias=True) self.init_offset()
Example #26
Source File: model.py From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self): super(LeNet, self).__init__() self.conv1 = nn.Conv2d(3, 6, 5) self.conv2 = nn.Conv2d(6, 16, 5) self.fc1 = nn.Linear(400, 120) self.fc2 = nn.Linear(120, 84) self.fc3 = nn.Linear(84, 10)
Example #27
Source File: googlenet.py From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, in_planes, n1x1, n3x3red, n3x3, n5x5red, n5x5, pool_planes): super(Inception, self).__init__() # 1x1 conv branch self.b1 = nn.Sequential( nn.Conv2d(in_planes, n1x1, kernel_size=1), nn.BatchNorm2d(n1x1), nn.ReLU(True), ) # 1x1 conv -> 3x3 conv branch self.b2 = nn.Sequential( nn.Conv2d(in_planes, n3x3red, kernel_size=1), nn.BatchNorm2d(n3x3red), nn.ReLU(True), nn.Conv2d(n3x3red, n3x3, kernel_size=3, padding=1), nn.BatchNorm2d(n3x3), nn.ReLU(True), ) # 1x1 conv -> 5x5 conv branch self.b3 = nn.Sequential( nn.Conv2d(in_planes, n5x5red, kernel_size=1), nn.BatchNorm2d(n5x5red), nn.ReLU(True), nn.Conv2d(n5x5red, n5x5, kernel_size=3, padding=1), nn.BatchNorm2d(n5x5), nn.ReLU(True), nn.Conv2d(n5x5, n5x5, kernel_size=3, padding=1), nn.BatchNorm2d(n5x5), nn.ReLU(True), ) # 3x3 pool -> 1x1 conv branch self.b4 = nn.Sequential( nn.MaxPool2d(3, stride=1, padding=1), nn.Conv2d(in_planes, pool_planes, kernel_size=1), nn.BatchNorm2d(pool_planes), nn.ReLU(True), )
Example #28
Source File: deform_conv.py From mmdetection with Apache License 2.0 | 5 votes |
def __init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, deformable_groups=1, bias=False): super(DeformConv, self).__init__() assert not bias assert in_channels % groups == 0, \ f'in_channels {in_channels} is not divisible by groups {groups}' assert out_channels % groups == 0, \ f'out_channels {out_channels} is not divisible ' \ f'by groups {groups}' self.in_channels = in_channels self.out_channels = out_channels self.kernel_size = _pair(kernel_size) self.stride = _pair(stride) self.padding = _pair(padding) self.dilation = _pair(dilation) self.groups = groups self.deformable_groups = deformable_groups # enable compatibility with nn.Conv2d self.transposed = False self.output_padding = _single(0) self.weight = nn.Parameter( torch.Tensor(out_channels, in_channels // self.groups, *self.kernel_size)) self.reset_parameters()
Example #29
Source File: resnext.py From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, num_blocks, cardinality, bottleneck_width, num_classes=10): super(ResNeXt, self).__init__() self.cardinality = cardinality self.bottleneck_width = bottleneck_width self.in_planes = 64 self.conv1 = nn.Conv2d(3, 64, kernel_size=1, bias=False) self.bn1 = nn.BatchNorm2d(64) self.layer1 = self._make_layer(num_blocks[0], 1) self.layer2 = self._make_layer(num_blocks[1], 2) self.layer3 = self._make_layer(num_blocks[2], 2) # self.layer4 = self._make_layer(num_blocks[3], 2) self.linear = nn.Linear(cardinality*bottleneck_width*8, num_classes)
Example #30
Source File: model.py From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self): super(CW_Net, self).__init__() self.conv1 = nn.Conv2d(3, 32, 3) self.conv2 = nn.Conv2d(32, 32, 3) self.conv3 = nn.Conv2d(32, 64, 3) self.conv4 = nn.Conv2d(64, 64, 3) self.fc1 = nn.Linear(1600, 200) self.fc2 = nn.Linear(200, 200) self.fc3 = nn.Linear(200, 2) # Change to 10, 2 is just dummy!!!!