Hi experts,
Need some clarification regarding the GAN C3W2A_Assignment UNQ_C3 ExpandingBlock.
Getting error for torch.cat([x, orginal_x], axis=1) in test_expanding_block():
test_samples: 100, test_channels: 10, test_size: 50
test_block: ExpandingBlock(
(upsample): Upsample(scale_factor=2.0, mode=bilinear)
(conv1): Conv2d(10, 5, kernel_size=(2, 2), stride=(1, 1))
(conv2): Conv2d(10, 5, kernel_size=(3, 3), stride=(1, 1))
(conv3): Conv2d(5, 5, kernel_size=(3, 3), stride=(1, 1))
(activation): ReLU()
)
skip_con_x shape: torch.Size([100, 5, 106, 106])
x shape: torch.Size([100, 10, 50, 50])
x upsample shape: torch.Size([100, 10, 100, 100])
x conv1 shape: torch.Size([100, 5, 99, 99])
assert 1
orginal_x shape: torch.Size([100, 5, 100, 100]), x.shape: torch.Size([100, 5, 99, 99])
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Input In [97], in <cell line: 37>()
34 assert tuple(x.shape) == (test_samples, test_channels // 2, test_size * 2 - 5, test_size * 2 - 5)
35 x = test_block.activation(x)
---> 37 test_expanding_block()
38 print("Success!")
Input In [97], in test_expanding_block(test_samples, test_channels, test_size)
25 orginal_x = crop(skip_con_x, x.shape)
26 print( f"orginal_x shape: {orginal_x.shape}, x.shape: {x.shape}" )
---> 27 x = torch.cat([x, orginal_x], axis=1)
28 x = test_block.conv2(x)
30 # Make sure that the second convolution produces the right shape
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 99 but got size 100 for tensor number 1 in the list.
So x image height and width reduced to 99 after conv1(). Is this correct?
Or is my crop() wrong although it passes test_expanding_block_crop().
crop() is achieved with image height and width dimensions slicing of original image.
Thanks,
MCW