Skip to content

Commit f5707b9

Browse files
committed
add hints for the encoder and decoder featuremaps.
1 parent 68876ee commit f5707b9

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

solution.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,11 @@ def forward(self, x):
588588
# <h4>Task 6: U-Net Implementation</h4>
589589
# <p>Now we will implement our U-Net! We have written some of it for you - follow the steps below to fill in the missing parts.</p>
590590
# <ol>
591-
# <li>Declare a list of encoder (left) and decoder (right) ConvBlocks. Carefully consider the input and output feature maps for each ConvPass!</li>
591+
# <li>Declare a list of encoder (left) and decoder (right) ConvBlocks. Carefully consider the input and output feature maps for each ConvPass!
592+
# <ul>
593+
# <li><strong>Hint:</strong> Consider implementing helper functions to calculate the encoder and decoder blocks separately - this will make your code more readable and easier to debug.</li>
594+
# </ul>
595+
# </li>
592596
# <li>Declare an Upsample, Downsample, CropAndConcat, and OutputConv block.</li>
593597
# <li>Implement the <code style="color: black">forward</code> function, applying the modules you declared above in the proper order.</li>
594598
# </ol>
@@ -661,7 +665,8 @@ def __init__(
661665
# TASK 6.1A: Initialize list here
662666
# Loop through each level of the encoder from top (level=0) to bottom (level=self.depth - 1)
663667
for level in range(self.depth):
664-
# conv =
668+
input_features,output_features = ...
669+
conv = ...
665670
# Adding conv module to the list
666671
self.left_convs.append(conv)
667672
# right convolutional passes
@@ -670,7 +675,8 @@ def __init__(
670675
# Loop through each level of the decoder from top (level=0) to one above bottom (level=self.depth - 2)
671676
for level in range(self.depth - 1):
672677
# Initialize conv module
673-
# conv =
678+
input_features,output_features = ...
679+
conv = ...
674680
# Adding conv module to the list
675681
self.right_convs.append(conv)
676682

@@ -693,6 +699,19 @@ def forward(self, x):
693699
# TASK 6.3D: Apply the final convolution and return the output
694700
return
695701

702+
def compute_fmaps_encoder(self, level: int) -> tuple[int, int]:
703+
"""Compute the number of input and output feature maps for
704+
a conv block at a given level of the UNet encoder (left side).
705+
"""
706+
return ...
707+
708+
def compute_fmaps_decoder(self, level: int) -> tuple[int, int]:
709+
"""Compute the number of input and output feature maps for a conv block
710+
at a given level of the UNet decoder (right side).
711+
"""
712+
713+
return ...
714+
696715

697716
# %% tags=["solution"]
698717
class UNet(torch.nn.Module):

0 commit comments

Comments
 (0)