def __init__(self, dims): super(Encoder, self).__init__() [x_dim, h_dim, z_dim] = dims self.linear = nn.Linear(x_dim, h_dim) self.batch_norm = nn.BatchNorm1d(h_dim) self.sample = GaussianSample(h_dim, z_dim)
def __init__(self, dims): super(Encoder, self).__init__() [x_dim, h_dim, z_dim] = dims neurons = [x_dim, *h_dim] linear_layers = [nn.Linear(neurons[i-1], neurons[i]) for i in range(1, len(neurons))] self.hidden = nn.ModuleList(linear_layers) self.sample = GaussianSample(h_dim[-1], z_dim)
def __init__(self, dims): super(LadderEncoder, self).__init__() [x_dim, h_dim, self.z_dim] = dims self.in_features = x_dim self.out_features = h_dim self.linear = nn.Linear(x_dim, h_dim) self.batchnorm = nn.BatchNorm1d(h_dim) self.sample = GaussianSample(h_dim, self.z_dim)
def __init__(self, dims): super(LadderDecoder, self).__init__() [x_dim, h_dim, self.z_dim] = dims self.linear1 = nn.Linear(x_dim, h_dim) self.batchnorm1 = nn.BatchNorm1d(h_dim) self.merge = GaussianMerge(h_dim, self.z_dim) self.linear2 = nn.Linear(x_dim, h_dim) self.batchnorm2 = nn.BatchNorm1d(h_dim) self.sample = GaussianSample(h_dim, self.z_dim)
def __init__(self, dims): super(Decoder, self).__init__() [z_dim, h_dim, x_dim] = dims # part 1 self.linear_1 = nn.Linear(x_dim, h_dim) self.batch_norm_1 = nn.BatchNorm1d(h_dim) self.merge = GaussianMerge(h_dim, z_dim) # part 2 self.linear_2 = nn.Linear(x_dim, h_dim) self.batch_norm_2 = nn.BatchNorm1d(h_dim) self.sample = GaussianSample(h_dim, z_dim)
def __init__(self, dims): """ The ladder encoder differs from the standard encoder by using batch-normalization and LReLU activation. Additionally, it also returns the transformation x. :param dims: dimensions [input_dim, [hidden_dims], [latent_dims]]. """ super(LadderEncoder, self).__init__() [x_dim, h_dim, self.z_dim] = dims self.in_features = x_dim self.out_features = h_dim self.linear = nn.Linear(x_dim, h_dim) self.batchnorm = nn.BatchNorm1d(h_dim) self.sample = GaussianSample(h_dim, self.z_dim)
def __init__(self, dims): """ The ladder dencoder differs from the standard encoder by using batch-normalization and LReLU activation. Additionally, it also returns the transformation x. :param dims: dimensions of the networks given by the number of neurons on the form [latent_dim, [hidden_dims], input_dim]. """ super(LadderDecoder, self).__init__() [self.z_dim, h_dim, x_dim] = dims self.linear1 = nn.Linear(x_dim, h_dim) self.batchnorm1 = nn.BatchNorm1d(h_dim) self.merge = GaussianMerge(h_dim, self.z_dim) self.linear2 = nn.Linear(x_dim, h_dim) self.batchnorm2 = nn.BatchNorm1d(h_dim) self.sample = GaussianSample(h_dim, self.z_dim)
def __init__(self, dims): """ Inference network Attempts to infer the probability distribution p(z|x) from the data by fitting a variational distribution q_φ(z|x). Returns the two parameters of the distribution (µ, log σ²). :param dims: dimensions of the networks given by the number of neurons on the form [input_dim, [hidden_dims], latent_dim]. """ super(Encoder, self).__init__() [x_dim, h_dim, z_dim] = dims neurons = [x_dim, *h_dim] linear_layers = [ nn.Linear(neurons[i - 1], neurons[i]) for i in range(1, len(neurons)) ] self.hidden = nn.ModuleList(linear_layers) self.sample = GaussianSample(h_dim[-1], z_dim)