def gan_critic(n_channels:int=3, nf:int=128, n_blocks:int=3, p:int=0.15):
    "Critic to train a `GAN`."
    layers = [
        _conv(n_channels, nf, ks=4, stride=2),
        nn.Dropout2d(p/2),
        res_block(nf, dense=True,**_conv_args)]
    nf *= 2 # after dense block
    for i in range(n_blocks):
        layers += [
            nn.Dropout2d(p),
            _conv(nf, nf*2, ks=4, stride=2, self_attention=(i==0))]
        nf *= 2
    layers += [
        _conv(nf, 1, ks=4, bias=False, padding=0, use_activ=False),
        Flatten()]
    return nn.Sequential(*layers)
def gan_critic ( n_channels : int = 3 , nf : int = 128 , n_blocks : int = 3 , p : int = 0.15 ) : layers = [ _conv ( n_channels , nf , ks = 4 , stride = 2 ) , nn . Dropout2d ( p / 2 ) , res_block ( nf , dense = True , ** _conv_args ) ] nf *= 2 for i in range ( n_blocks ) : layers += [ nn . Dropout2d ( p ) , _conv ( nf , nf * 2 , ks = 4 , stride = 2 , self_attention = ( i == 0 ) ) ] nf *= 2 layers += [ _conv ( nf , 1 , ks = 4 , bias = False , padding = 0 , use_activ = False ) , Flatten ( ) ] return nn . Sequential ( * layers )
Critic to train a `GAN`.