def __init__(self, cfg, net1, net2):
    super(NDDRNet, self).__init__()
    self.cfg = cfg
    self.net1 = net1
    self.net2 = net2
    assert (len(net1.stages) == len(net2.stages))
    (self.task1, self.task2) = get_tasks(cfg)
    self.num_stages = len(net1.stages)
    nddrs = []
    total_channels = 0
    for stage_id in range(self.num_stages):
        out_channels = net1.stages[stage_id].out_channels
        assert (out_channels == net2.stages[stage_id].out_channels)
        if (stage_id in cfg.TRAIN.AUX_LAYERS):
            total_channels += out_channels
        nddr = get_nddr(cfg, out_channels, out_channels)
        nddrs.append(nddr)
    nddrs = nn.ModuleList(nddrs)
    self.aux = cfg.TRAIN.AUX
    if self.aux:
        print('Using shortcut')
        self.aux_conv1 = nn.Sequential(nn.Conv2d(total_channels, 256, kernel_size=3, padding=1, bias=False), batch_norm(256, eps=0.001, momentum=cfg.MODEL.BATCH_NORM_MOMENTUM), nn.ReLU(inplace=True), nn.Dropout2d(p=0.5), nn.Conv2d(256, cfg.MODEL.NET1_CLASSES, kernel_size=1))
        self.aux_conv2 = nn.Sequential(nn.Conv2d(total_channels, 256, kernel_size=3, padding=1, bias=False), batch_norm(256, eps=0.001, momentum=cfg.MODEL.BATCH_NORM_MOMENTUM), nn.ReLU(inplace=True), nn.Dropout2d(p=0.5), nn.Conv2d(256, cfg.MODEL.NET2_CLASSES, kernel_size=1))
    self.nddrs = nn.ModuleDict({'nddrs': nddrs})
    self._step = 0
def __init__(self, cfg, net1, net2):
    super(NDDRNet, self).__init__()
    self.cfg = cfg
    self.net1 = net1
    self.net2 = net2
    assert (len(net1.stages) == len(net2.stages))
    (self.task1, self.task2) = get_tasks(cfg)
    self.num_stages = len(net1.stages)
    nddrs = []
    total_channels = 0
    for stage_id in range(self.num_stages):
        out_channels = net1.stages[stage_id].out_channels
        assert (out_channels == net2.stages[stage_id].out_channels)
        if (stage_id in cfg.TRAIN.AUX_LAYERS):
            total_channels += out_channels
        nddr = get_nddr(cfg, out_channels, out_channels)
        nddrs.append(nddr)
    nddrs = nn.ModuleList(nddrs)
    self.aux = cfg.TRAIN.AUX
    if self.aux:
        print('Using shortcut')
        self.aux_conv1 = nn.Sequential(nn.Conv2d(total_channels, 256, kernel_size=3, padding=1, bias=False), batch_norm(256, eps=0.001, momentum=cfg.MODEL.BATCH_NORM_MOMENTUM), nn.ReLU(inplace=True), nn.Dropout2d(p=0.5), nn.Conv2d(256, cfg.MODEL.NET1_CLASSES, kernel_size=1))
        self.aux_conv2 = nn.Sequential(nn.Conv2d(total_channels, 256, kernel_size=3, padding=1, bias=False), batch_norm(256, eps=0.001, momentum=cfg.MODEL.BATCH_NORM_MOMENTUM), nn.ReLU(inplace=True), nn.Dropout2d(p=0.5), nn.Conv2d(256, cfg.MODEL.NET2_CLASSES, kernel_size=1))
    self.nddrs = nn.ModuleDict({'nddrs': nddrs})
    self._step = 0