Need help with C2W3 UNQ_C3

I’m at my wits’ end with InjectNoise. I just can’t pass the unit test so I’m hoping for help here.

It seems very easy - I know what the noise shape should be (the hint tells you) so I’m using that shape as an argument to torch.randn() which is passed in as an agument to nn.Parameter in the init function.

Then in the forward function the shape should be (1,1,r,c) where r and c are the image row and column sizes (both equal to 10 in the unit test) which I get from image.shape. The instructions say to generate a single channel of noise so this shape seems right. At any rate, I’ve tried all sensible combinations of other values from the image shape with no success.

However, I can’t pass line 15 in the unit test because I’m getting a small value for the mean std over channel 0 instead of a value > 1e-4.

Any help is appreciated. Thanks in advance!

Nevermind!

Of course I got it to work shortly after posting this question.
For anyone else who might have been confused, the tensor with noise in a single channel still needs to be as big as the number of images.

1 Like

Welcome to the community Rob_C!
Hope you are doing well!
Yes, you should take care of the complete shape.
Regards,
Nithin

I have: noise_shape = (test_noise_samples, test_noise_channels, 10, 10)
and the test assert torch.abs((inject_noise(fake_images) - fake_images).std(2)).mean() < 1e-4 fails.
I find that strange. This part should not be hard.