Skip to content

Commit c29a30d

Browse files
style: 💬 update some task text and doc strings
1 parent 7f1ea1f commit c29a30d

1 file changed

Lines changed: 27 additions & 10 deletions

File tree

solution.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ def forward(self, x):
283283
# <ol>
284284
# <li>Declare the submodules you want to use in the <code style="color: black">__init__</code> function. Because you will always be calling four submodules in sequence (<a href=https://pytorch.org/docs/stable/generated/torch.nn.Conv2d.html#torch.nn.Conv2d>torch.nn.Conv2d</a>, <a href=https://pytorch.org/docs/stable/generated/torch.nn.ReLU.html#torch.nn.ReLU>torch.nn.ReLU</a>, Conv2d, ReLU), you can use <a href=https://pytorch.org/docs/stable/generated/torch.nn.Sequential.html>torch.nn.Sequential</a> to hold the convolutions and ReLUs.</li>
285285
# <li>Call the modules in the forward function. If you used <code style="color: black">torch.nn.Sequential</code> in step 1, you only need to call the Sequential module, but if not, you can call the Conv2d and ReLU Modules explicitly.</li>
286-
# </ol>
286+
# <li>Visualize the output and maybe rerun the cell to see how the output changes. Can you explain what you see?</li>
287+
# </ol>
287288
# </div>
288289
#
289290
# If you get stuck, refer back to the <a href=https://pytorch.org/docs/stable/notes/modules.html>Module</a> documentation for hints and examples of how to define a PyTorch Module.
@@ -590,7 +591,7 @@ def forward(self, x):
590591
# <ol>
591592
# <li>Declare a list of encoder (left) and decoder (right) ConvBlocks. Carefully consider the input and output feature maps for each ConvPass!
592593
# <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+
# <li><strong>Hint:</strong> We provided scaffolding to implement helper functions to calculate the encoder and decoder blocks separately - this will make your code more readable. But feel free to ignore them if you find it confusing.</li>
594595
# </ul>
595596
# </li>
596597
# <li>Declare an Upsample, Downsample, CropAndConcat, and OutputConv block.</li>
@@ -702,16 +703,32 @@ def forward(self, x):
702703
def compute_fmaps_encoder(self, level: int) -> tuple[int, int]:
703704
"""Compute the number of input and output feature maps for
704705
a conv block at a given level of the UNet encoder (left side).
706+
707+
Args:
708+
level (int): The level of the U-Net which we are computing
709+
the feature maps for. Level 0 is the input level, level 1 is
710+
the first downsampled layer, and level=depth - 1 is the bottom layer.
711+
712+
Output (tuple[int, int]): The number of input and output feature maps
713+
of the encoder convolutional pass in the given level.
705714
"""
706-
return ...
707-
715+
pass
716+
708717
def compute_fmaps_decoder(self, level: int) -> tuple[int, int]:
709718
"""Compute the number of input and output feature maps for a conv block
710-
at a given level of the UNet decoder (right side).
719+
at a given level of the UNet decoder (right side). Note:
720+
The bottom layer (depth - 1) is considered an "encoder" conv pass,
721+
so this function is only valid up to depth - 2.
722+
723+
Args:
724+
level (int): The level of the U-Net which we are computing
725+
the feature maps for. Level 0 is the input level, level 1 is
726+
the first downsampled layer, and level=depth - 1 is the bottom layer.
727+
728+
Output (tuple[int, int]): The number of input and output feature maps
729+
of the encoder convolutional pass in the given level.
711730
"""
712-
713-
return ...
714-
731+
pass
715732

716733
# %% tags=["solution"]
717734
class UNet(torch.nn.Module):
@@ -1245,8 +1262,8 @@ def launch_tensorboard(log_dir):
12451262
#
12461263
# Congratulations! You trained your first UNet that you implemented all by yourself!
12471264
#
1248-
# We will keep using this U-Net throughout the rest of the exercises. Whenever you see an import like `import dlmbl-unet` or
1249-
# `from dlmbl-unet import UNet` it will be importing from [this repository](https://github.com/dlmbl/dlmbl-unet) which contains the solution to this notebook as a package (including the bonus exercises so don't peek just yet if you wanna solve the bonus too).
1265+
# We will keep using this U-Net throughout the rest of the exercises. Whenever you see an import like `import dlmbl_unet` or
1266+
# `from dlmbl_unet import UNet` it will be importing from [this repository](https://github.com/dlmbl/dlmbl-unet) which contains the solution to this notebook as a package (including the bonus exercises so don't peek just yet if you wanna solve the bonus too).
12501267
# </div>
12511268

12521269
# %% [markdown] tags=[]

0 commit comments

Comments
 (0)