Hello,
I try to complete the final assignment of week 3 of Cours 2 of Speiclaization on the Gan and i
have an error on the tests following my implementation of the Injectnoise function, I cannot decipher the root cause of this error, I am confused because the initialization of the Weights seems correct with
Self.weight = nn.parameter (torch.randn ((1, channels, 1, 1)))) and on the Forward function the noise shape is the same as the image shape
def Forward (self, image):
noise_shape = (image.shape [0], image.shape [1], image.shape [2], image.shape [3]).
All the tests have passed with success with the exception of the follwing test
asserts per_channel_change> 0.9 and per_channel_change <1.1
which does not pass since I have a smaller value than 0.9 (0.0186).
If someone manages to see what I missed their help is greatly appreciated
Thank you
Hi Touzani!
Hope you are doing well.
The noise_shape is set as (image.shape[0], image.shape[1], image.shape[2], image.shape[3])
, which means that the number of channels in the noise tensor is the same as the number of channels in the input image (image.shape[1]
). This would result in noise being added to each channel separately, rather than a single noise map being added to the entire image. Here we want to apply it to the image after multiplying by the weight for each channel. So, kindly work on doing it. If you face any issues, feel free to post your queries.
Regards,
Nithin
1 Like
Thanks for your answers. its indeed how i implement the thing. btw i already succes to submit the final assignement it turns out that it was only some technical issue reate to network i applied it again it work. i keep the same thing : same weight initialization using torch.randn and same noise shape (the one i mention and you mention in your answer).
Thanks
Best regards.
Hi, I set
Self.weight = nn.parameter (torch.randn ((1, channels, 1, 1)))
but, it does not work.
(TypeError: randn(): argument ‘size’ must be tuple of ints, but found element of type Tensor at pos 1)
I think all values are set as int, so how can I deal with this.
Best regards
Hi,
I think it’s interpreting (1, channels, 1, 1) as a tensor, just pass the size as a sequence of integers, i. e., remove the parenthesis.
Best regards.
Weird to encounter such issues. It should be working. And also channels
parameter is passed by unit test blocks, so pls check if you have changed anything in the unit test blocks by mistake. If you still face such issues, feel free to post it.
Regards,
Nithin
A good way to check for the type of thing that Nithin is suggesting is to get a clean copy of the notebook, so that you can compare the test cells to make sure you didn’t accidentally (or purposefully) change the tests. Here’s a thread that gives instructions for how to do that.
If the tests fail, the solution is not to change the tests. 