To get test row 8 (
test_x = test_stylegan_block.conv(test_x)
) to work I needed to set:
self.inject_noise = InjectNoise(3000)
which is a bit strange with hardcoding. But, now the next test does not work.
Se below:
RuntimeError Traceback (most recent call last)
in
8 test_x = test_stylegan_block.conv(test_x)
9 assert tuple(test_x.shape) == (1, 64, 8, 8)
—> 10 test_x = test_stylegan_block.inject_noise(test_x)
11 test_x = test_stylegan_block.activation(test_x)
12 assert test_x.min() < 0/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
548 result = self._slow_forward(*input, **kwargs)
549 else:
→ 550 result = self.forward(*input, **kwargs)
551 for hook in self._forward_hooks.values():
552 hook_result = hook(self, input, result)in forward(self, image)
36
37 noise = torch.randn(noise_shape, device=image.device) # Creates the random noise
—> 38 return image + self.weight * noise # Applies to image after multiplying by the weight for each channel
39
40 #UNIT TEST COMMENT: Required for gradingRuntimeError: The size of tensor a (8) must match the size of tensor b (10) at non-singleton dimension 3
My values for the task are:
if self.use_upsample:
self.upsample = nn.Upsample((starting_size, starting_size), mode='bilinear')
self.conv = nn.Conv2d(in_chan, out_chan, kernel_size, padding=int(out_chan/64)) # Padding is used to maintain the image size
self.inject_noise = InjectNoise(3000)
What is causing this?