Issue in BicycleGAN paper

arnabsinha: <p>In the BicycleGAN paper ( <a href="https://arxiv.org/pdf/1711.11586.pdf" rel="nofollow noopener">https://arxiv.org/pdf/1711.11586.pdf</a> ), the Pytorch implemented code has the following function implemented:</p>
<aside class="onebox githubblob">
  <header class="source">
      <a href="https://github.com/junyanz/BicycleGAN/blob/0d7459a6b1eb577e024a5165097f0ae1609d0040/models/networks.py#L623" target="_blank" rel="nofollow noopener">github.com</a>
  </header>
  <article class="onebox-body">
    <h4><a href="https://github.com/junyanz/BicycleGAN/blob/0d7459a6b1eb577e024a5165097f0ae1609d0040/models/networks.py#L623" target="_blank" rel="nofollow noopener">junyanz/BicycleGAN/blob/0d7459a6b1eb577e024a5165097f0ae1609d0040/models/networks.py#L623</a></h4>
<pre class="onebox"><code class="lang-py"><ol class="start lines" start="613" style="counter-reset: li-counter 612 ;">
<li>        layers += [nl_layer()]</li>
<li>        layers += [convMeanpool(inplanes, outplanes)]</li>
<li>        self.conv = nn.Sequential(*layers)</li>
<li>        self.shortcut = meanpoolConv(inplanes, outplanes)</li>
<li>
</li><li>    def forward(self, x):</li>
<li>        out = self.conv(x) + self.shortcut(x)</li>
<li>        return out</li>
<li>
</li><li>
</li><li class="selected">class E_ResNet(nn.Module):</li>
<li>    def __init__(self, input_nc=3, output_nc=1, ndf=64, n_blocks=4,</li>
<li>                 norm_layer=None, nl_layer=None, vaeLike=False):</li>
<li>        super(E_ResNet, self).__init__()</li>
<li>        self.vaeLike = vaeLike</li>
<li>        max_ndf = 4</li>
<li>        conv_layers = [</li>
<li>            nn.Conv2d(input_nc, ndf, kernel_size=4, stride=2, padding=1, bias=True)]</li>
<li>        for n in range(1, n_blocks):</li>
<li>            input_ndf = ndf * min(max_ndf, n)</li>
<li>            output_ndf = ndf * min(max_ndf, n + 1)</li>
</ol></code></pre>


  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>

<p>Could anyone confirm with me if the forward function is returning <strong>output</strong> as a 1x1 dimensional vector representing the point estimate of the predicted mean?</p>
<p>If so, in the following function, is this value of mean i.e. <strong>mu</strong> broadcasted to a |z| dimensional vector using the reparameterization trick?</p>
<aside class="onebox githubblob">
  <header class="source">
      <a href="https://github.com/junyanz/BicycleGAN/blob/0d7459a6b1eb577e024a5165097f0ae1609d0040/models/bicycle_gan_model.py#L81" target="_blank" rel="nofollow noopener">github.com</a>
  </header>
  <article class="onebox-body">
    <h4><a href="https://github.com/junyanz/BicycleGAN/blob/0d7459a6b1eb577e024a5165097f0ae1609d0040/models/bicycle_gan_model.py#L81" target="_blank" rel="nofollow noopener">junyanz/BicycleGAN/blob/0d7459a6b1eb577e024a5165097f0ae1609d0040/models/bicycle_gan_model.py#L81</a></h4>
<pre class="onebox"><code class="lang-py"><ol class="start lines" start="71" style="counter-reset: li-counter 70 ;">
<li>    self.real_B = input['B' if AtoB else 'A'].to(self.device)</li>
<li>    self.image_paths = input['A_paths' if AtoB else 'B_paths']</li>
<li>
</li><li>def get_z_random(self, batch_size, nz, random_type='gauss'):</li>
<li>    if random_type == 'uni':</li>
<li>        z = torch.rand(batch_size, nz) * 2.0 - 1.0</li>
<li>    elif random_type == 'gauss':</li>
<li>        z = torch.randn(batch_size, nz)</li>
<li>    return z.to(self.device)</li>
<li>
</li><li class="selected">def encode(self, input_image):</li>
<li>    mu, logvar = self.netE.forward(input_image)</li>
<li>    std = logvar.mul(0.5).exp_()</li>
<li>    eps = self.get_z_random(std.size(0), std.size(1))</li>
<li>    z = eps.mul(std).add_(mu)</li>
<li>    return z, mu, logvar</li>
<li>
</li><li>def test(self, z0=None, encode=False):</li>
<li>    with torch.no_grad():</li>
<li>        if encode:  # use encoded z</li>
<li>            z0, _ = self.netE(self.real_B)</li>
</ol></code></pre>


  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>


ptrblck: <p>You could add print statements to the methods in question and print the shape of the tensors as well as parameters.<br>
Let me know, if I misunderstood the question. <img src="https://discuss.pytorch.org/images/emoji/apple/wink.png?v=9" title=":wink:" class="emoji" alt=":wink:"></p>

arnabsinha: <p>Yes I was thinking of cloning the repo but I am afraid my laptop might not have the required specs or might hang during the training. I am eagerly waiting for codespaces on GitHub for that. I shall try to reduce the training set size. Could you figure out from the snippet posted above about the shape of the <strong>output</strong> variable?</p>