|
4 | 4 |
|
5 | 5 | def find_fc_input_shape(image_shape, model): |
6 | 6 | """ |
7 | | - Find the shape of the input to the fully connected layer after passing through the convolutional layers. |
8 | | -
|
9 | | - Code inspired by @Seilmast (https://github.com/SFI-Visual-Intelligence/Collaborative-Coding-Exam/issues/67#issuecomment-2651212254) |
10 | | -
|
11 | | - Args |
12 | | - ---- |
13 | | - image_shape : tuple(int, int, int) |
14 | | - Shape of the input image (C, H, W), where C is the number of channels, |
15 | | - H is the height, and W is the width of the image. |
16 | | - model : nn.Module |
17 | | - The CNN model containing the convolutional layers, whose output size is used to |
18 | | - determine the number of input features for the fully connected layer. |
19 | | -
|
20 | | - Returns |
21 | | - ------- |
22 | | - int |
23 | | - The number of elements in the input to the fully connected layer. |
24 | | - """ |
| 7 | + Find the shape of the input to the fully connected layer after passing through the convolutional layers. |
| 8 | +
|
| 9 | + Code inspired by @Seilmast (https://github.com/SFI-Visual-Intelligence/Collaborative-Coding-Exam/issues/67#issuecomment-2651212254) |
| 10 | +
|
| 11 | + Args |
| 12 | + ---- |
| 13 | + image_shape : tuple(int, int, int) |
| 14 | + Shape of the input image (C, H, W), where C is the number of channels, |
| 15 | + H is the height, and W is the width of the image. |
| 16 | + model : nn.Module |
| 17 | + The CNN model containing the convolutional layers, whose output size is used to |
| 18 | + determine the number of input features for the fully connected layer. |
| 19 | +
|
| 20 | + Returns |
| 21 | + ------- |
| 22 | + int |
| 23 | + The number of elements in the input to the fully connected layer. |
| 24 | + """ |
25 | 25 |
|
26 | 26 | dummy_img = torch.randn(1, *image_shape) |
27 | 27 | with torch.no_grad(): |
|
0 commit comments