MCPcopy Create free account
hub / github.com/Vchitect/Latte / __init__

Method __init__

tools/utils/layers.py:24–66  ·  view source on GitHub ↗
(self,
        z_dim,                      # Input latent (Z) dimensionality, 0 = no latent.
        c_dim,                      # Conditioning label (C) dimensionality, 0 = no label.
        w_dim,                      # Intermediate latent (W) dimensionality.
        num_ws,                     # Number of intermediate latents to output, None = do not broadcast.
        num_layers      = 8,        # Number of mapping layers.
        embed_features  = None,     # Label embedding dimensionality, None = same as w_dim.
        layer_features  = None,     # Number of intermediate features in the mapping layers, None = same as w_dim.
        activation      = 'lrelu',  # Activation function: 'relu', 'lrelu', etc.
        lr_multiplier   = 0.01,     # Learning rate multiplier for the mapping layers.
        w_avg_beta      = 0.995,    # Decay for tracking the moving average of W during training, None = do not track.
        cfg             = {},       # Additional config
    )

Source from the content-addressed store, hash-verified

22@persistence.persistent_class
23class MappingNetwork(torch.nn.Module):
24 def __init__(self,
25 z_dim, # Input latent (Z) dimensionality, 0 = no latent.
26 c_dim, # Conditioning label (C) dimensionality, 0 = no label.
27 w_dim, # Intermediate latent (W) dimensionality.
28 num_ws, # Number of intermediate latents to output, None = do not broadcast.
29 num_layers = 8, # Number of mapping layers.
30 embed_features = None, # Label embedding dimensionality, None = same as w_dim.
31 layer_features = None, # Number of intermediate features in the mapping layers, None = same as w_dim.
32 activation = 'lrelu', # Activation function: 'relu', 'lrelu', etc.
33 lr_multiplier = 0.01, # Learning rate multiplier for the mapping layers.
34 w_avg_beta = 0.995, # Decay for tracking the moving average of W during training, None = do not track.
35 cfg = {}, # Additional config
36 ):
37 super().__init__()
38
39 self.cfg = cfg
40 self.z_dim = z_dim
41 self.c_dim = c_dim
42 self.w_dim = w_dim
43 self.num_ws = num_ws
44 self.num_layers = num_layers
45 self.w_avg_beta = w_avg_beta
46
47 if embed_features is None:
48 embed_features = w_dim
49 if c_dim == 0:
50 embed_features = 0
51 if layer_features is None:
52 layer_features = w_dim
53
54 features_list = [z_dim + embed_features] + [layer_features] * (num_layers - 1) + [w_dim]
55
56 if c_dim > 0:
57 self.embed = FullyConnectedLayer(c_dim, embed_features)
58
59 for idx in range(num_layers):
60 in_features = features_list[idx]
61 out_features = features_list[idx + 1]
62 layer = FullyConnectedLayer(in_features, out_features, activation=activation, lr_multiplier=lr_multiplier)
63 setattr(self, f'fc{idx}', layer)
64
65 if num_ws is not None and w_avg_beta is not None:
66 self.register_buffer('w_avg', torch.zeros([w_dim]))
67
68 def forward(self, z, c, truncation_psi=1, truncation_cutoff=None, skip_w_avg_update=False):
69 # Embed, normalize, and concat inputs.

Callers

nothing calls this directly

Calls 2

FullyConnectedLayerClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected