The following code, I hope to add a class “preprocess” for NN. However, I get the error:torch.nn.modules.module.ModuleAttributeError: ‘Darknet’ object has no attribute ‘prePrp’
import torch.nn as nn
class preprocess(nn.Module):
    def __init__(self):
        super(preprocess, self).__init__()
    def forward(self, x):
        print('here')
        return x + 200
class SuperResolutionNet(nn.Module):
    def __init__(self):
        super(SuperResolutionNet, self).__init__()
        self.relu = nn.ReLU(inplace=False)
        self.conv1 = nn.Conv2d(1, 64, (5, 5), (1, 1), (2, 2))
        self.modules = self.creat_network()
        self.prePrp = preprocess()

    def creat_network(self):
        models = nn.ModuleList()
        models.append(self.prePrp)
        model = nn.Sequential()
        model.add_module('conv{0}'.format(1),
                         nn.Conv2d(3, 64, 3, 1, 0, bias=False))
        model.add_module('bn{0}'.format(1), nn.BatchNorm2d(3))
        models.append(model)

    def forward(self, x):
        for m in self.modules:
            x = m(x)
        return x

torch_model = SuperResolutionNet()
print(torch_model)


Thank you very much