How to call one layer in CNN

I define a discriminator as follow:

class D(nn.Module):
def init(self, ngpu):
self.main = nn.Sequential(OrderedDict([
(‘conv1’, nn.Conv2d()),
(‘relu1’, nn.ReLU()),
‘conv2’, nn.Conv2d())
(‘out’, nn.Signoid())

and I want to use modify one layer by
but it doesn’t work because “D” object has not attribute “conv1”

thank you

Your code has no initializer __init__. Try the following code:

import torch
import torch.nn as nn
from collections import OrderedDict

class Discriminator(nn.Module):
    def __init__(self):
        super(Discriminator, self).__init__() = nn.Sequential(OrderedDict([
          ('conv1', nn.Conv2d(1,20,5)),
          ('relu1', nn.ReLU()),
          ('conv2', nn.Conv2d(20,64,5)),
          ('relu2', nn.ReLU())

    def forward(self, x):

d = Discriminator()

thank you! in fact I lost the “.net”