question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What is the network structure to generate mean and std for sampling process in the training phase?

See original GitHub issue

I am trying to reproduce the result of variational autoencoder part of the entire network. Since the training code was not released yet, I can only guess you are doing something like the following code.

I trained with this structure, but found it is really hard to get a descent result. I am wondering if you could provide more training details, such as complete network structure for training, training time, if there are some special training strageties and tricks.

        self.encoder_latent = nn.Sequential(*model)
        self.mu = ResnetBlock(min(ngf * mult * 2, opt.mc),
                              padding_type=padding_type,
                              activation=activation,
                              norm_layer=norm_layer,
                              opt=opt,
                              )
        self.log_var = ResnetBlock(min(ngf * mult * 2, opt.mc),
                                   padding_type=padding_type,
                                   activation=activation,
                                   norm_layer=norm_layer,
                                   opt=opt,
                                   )
        model += [self.mu]

        # model += [nn.Conv2d(min(ngf * mult * 2, opt.mc), min(ngf, opt.mc), 1, 1)]
        if opt.feat_dim > 0:
            # 1*1 conv
            model += [nn.Conv2d(min(ngf * mult * 2, opt.mc), opt.feat_dim, 1, 1)]

        self.encoder = nn.Sequential(*model)

    def train_forward(self, input):
        latent = self.encoder_latent(input)
        mu = self.mu(latent)
        log_var = self.log_var(latent)
        z = self.sample(mu, log_var)
        return self.decoder(z), mu, log_var

    def sample(self, mu, log_var):
        std = torch.exp(log_var * 0.5)
        eps = torch.randn_like(mu)
        return mu + std * eps

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
Zeqiang-Laicommented, Dec 9, 2020

the common practice usually uses fully connected layers

Yes, pytorch VAE examples also use fully connected layers For me, I think using fc layers could save the global info, while using 1*1 conv will only have local receptive field. Correct me if I am wrong

I currently use two 1*1 convolutions as it is suggested in the test code

where is the suggestion in code, I couldnt find it

sorry, my fault, it’s two resnet blocks. The test code directly use mean from the encoder and feed it into the decoder(see Link. So the last layer of the encoder should output mean. As it is shown in the test code, the block to output mean is a resnet block (in testing, feat_dim = -1, so the last 1*1 convolution is not used)

        model += [
            ResnetBlock(
                min(ngf * mult * 2, opt.mc),
                padding_type=padding_type,
                activation=activation,
                norm_layer=norm_layer,
                opt=opt,
            )
        ]
        # model += [nn.Conv2d(min(ngf * mult * 2, opt.mc), min(ngf, opt.mc), 1, 1)]
        if opt.feat_dim > 0:
            model += [nn.Conv2d(min(ngf * mult * 2, opt.mc), opt.feat_dim, 1, 1)]
        self.encoder = nn.Sequential(*model)

0reactions
Jak0917377107commented, Mar 10, 2021

README.md

Read more comments on GitHub >

github_iconTop Results From Across the Web

Applied Deep Learning - Part 3: Autoencoders | by Arden Dertat
Autoencoders are a specific type of feedforward neural networks where the input is the same as the output. They compress the input into...
Read more >
1 Computing the Standard Deviation of Sample Means
Quality control charts are based on sample means not on individual values within a sample. A sample is a group of items, which...
Read more >
Generative Adversarial Networks: Build Your First Models
The GAN training process consists of a two-player minimax game in which D is adapted to minimize the discrimination error between real and...
Read more >
A Gentle Introduction to Generative Adversarial Networks ...
GANs are an architecture for automatically training a generative model by treating the ... The generator network directly produces samples.
Read more >
Standards and Guidelines for Statistical Surveys - SAMHSA
nonprobability sampling methods (e.g., cut-off or model-based samples) must be ... surveys and other means of collecting data” into the single section on ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found