Example #1
0
def ResNetLarge_LargeCombo(c, **kargs): # resnetWide also used by mixtrain and scaling provable adversarial defenses
    def wb(c, bias = True, **kargs):
        return n.WideBlock(c, False, bias=bias, ibp_init=True, batch_norm = False, **kargs)
    dl = n.DeepLoss
    cmk = n.CorrMaxK
    cm2d = n.CorrMaxPool2D
    cm3d = n.CorrMaxPool3D
    dec = lambda x: n.DecorrMin(x, num_to_keep = True)
    return n.Seq(n.Conv(16, 3, padding=1, bias=True, ibp_init = True), cmk(4),
                 wb(16), cmk(4), dec(4),
                 wb(32), cmk(4), dec(4),
                 wb(32), dl(S.Until(1, 0, S.Lin(0.5, 0, 50, 3))),
                 wb(32), cmk(4), dec(4),
                 wb(64), cmk(4), dec(2),
                 wb(64), dl(S.Until(24, S.Lin(0, 0.1, 20, 4), S.Lin(0.1, 0, 50))),
                 wb(64),
                 n.FFNN([1000, c], bias=True, last_lin=True, ibp_init = True, **kargs))
Example #2
0
def SkipNet18_Combo(c, **kargs):
    dl = n.DeepLoss
    cmk = n.CorrFix
    dec = lambda x: n.DecorrMin(x, num_to_keep=True)
    return n.Seq(
        n.ResNet([2, 2, 2, 2],
                 extra=[(cmk(20), 2), (dec(10), 2), (cmk(10), 3), (dec(5), 3),
                        (dl(S.Until(90, S.Lin(0, 0.2, 50, 40), 0)), 3),
                        (cmk(5), 4), (dec(2), 4)],
                 bias=True,
                 ibp_init=True,
                 skip_net=True),
        n.FFNN([512, 512, c],
               bias=True,
               last_lin=True,
               last_zono=True,
               ibp_init=True,
               **kargs))