Memuat
Memuat
Watch every step above performed live, with English narration.
0 plays
Class book
Page 1 / 7
Cover: Class U-Net Brain Tumor Segmentation #3: Building U-Net from Scratch: Encoder, Decoder & Skip Connection
Click a page or use ◀ ▶ to turn · swipe on mobile · to enlarge
Want to go deeper?
Join one of our courses or ask us directly on WhatsApp.
Picked from the software, topic, and level of “Class Brain Tumor Segmentation with U-Net #3: Building U-Net from Scratch: Encoder, Decoder & Skip Connection”.
Other ways we can help with Python.
Learn with a mentor
Scheduled AI & Machine Learning courses with live guidance and a certificate.

Multi-Objective Optimization Course: NSGA-II, MOPSO & Hybrid Algorithms (Python)

ECG Arrhythmia Classification Course with Wavelet & Deep Learning (PyTorch)

ANFIS + PSO/GA Course for Non-Linear Time Series Forecasting (Python)
Have it built for you
No time to learn Python? Our team can do the project for you.

Python Machine Learning — Prediction Models, Customer Segmentation, Fraud Detection & AI Apps

AI Image Creation with Stable Diffusion — Unlimited Custom Visual Production
★ 4.9

AI Image & Video Creation with Leonardo AI — All-in-One Visuals for Business
★ 4.9
Get notified about new Python classes
At most one email a week. Unfollow anytime with one click.
The full narration of this video. The current sentence is highlighted while the video plays; click any sentence to jump there.
This is the final result, the UNET architecture we wrote ourselves with PyTorch, from 96 pixel images down to 12 pixel bottleneck, then up again to the segmentation map. And the overfit test proves our UNET can draw the tumor. Let's start. Hello, welcome to episode three of the brain tumor segmentation series with the metaheuristic optimized UNET. UNET was introduced in 2015 specifically for biomedical image segmentation, and until now it has become the base model in almost all medical segmentation research. Today we are building it from scratch, line by line, so that you truly understand how it works, then we will test it before real training.
Create a file UNET.py The basic component is the convolution block, 2x conv2d 3x3, each followed by BatchNorm and ReLU. Padding 1 keeps the image size the same. At the end of the block there is a 2D dropout which is by default 0, its value will later become one of the hyperparameters to be optimized.
Now the UNET class. Parameter F is the number of filters at the first level. The encoder has 3 blocks with filters F, 2F, and 4F, separated by Max Pooling which halves the image size. The bottleneck at the bottom of the U letter has 8F filters. The decoder is the opposite, conv transpose 2 which doubles the feature map size twice, then the convolution block. The last convolution layer 1x1 produces one channel, which is the tumor score for each pixel.
Look at the forward function. This is the key of UNET, skip connection. Before entering the decoder block, the sampled loop result is combined with the encoder features from the same level. The encoder knows what the image contains but loses location details due to pooling. Skip connection restores those location details, so the tumor boundary can be drawn sharply. Now create a file check_underscore_unit.py to check the tensor shape at each level.
Run. Input 3 channel 96 pixel. Encoder 1 produces 16 channels at the same size, then 32 channels at 48 pixel, 64 channels at 24 pixel, and bottleneck 128 channels at 12 pixel. Output returns to 96x96 with 1 channel. Total of 483 thousand parameters.
Before long training, a good researcher performs overfitting test. Train the model on a small 1B only. If the model cannot memorize 8 images, there must be a bug. We take 8 slices with the largest tumor, then train for 60 steps. Loss drops from 0.43 to 0.04. The image, top row is the original mask, bottom row is prediction. Location and shape of the tumor are already suitable, edges are still smooth because it's only 60 steps. It means our unit is working. Done. We have built the unit from scratch with encoder, bottleneck, decoder, and skip connection,
checking the tensor shape at each level, and passed the overfitting test. In the next episode, we will discuss the loss specific to segmentation. DAIS, IOU, and BCI DAIS, then fully train the baseline unit. Currently working on a thesis, dissertation, or AI research in the field of medical image segmentation? Cerdas Inovasi Digital helps with deep learning implementation, from UNET segmentation, heuristic optimization with PSO and Grey Wolf, up to DAIS, IOU evaluation, and result writing, as well as opening deep learning courses with PyTor. Want to master the entire series, from MRI brain dataset to heuristic optimized UNET? All 6 episodes, complete with PDF step-by-step guides and source code, are available for premium tutorial subscribers. Subscribe starting from Rp69.000 per month Save 28% with the 12-month package, or pay once Rp999.000 for lifetime access. Want a single class only? Buy single classes with lifetime access. Subscribe now on the premium page cerdasinovasidigital.com. Contact our WhatsApp, or visit cerdasinovasidigital.com. Thank you for watching, see you in the next episode.
Type a question or keyword; we find the part of this episode that explains it and jump the video there.
Notes are saved with the current video time and are only visible to you.
Stuck on a step? Ask here; the instructor and other learners can answer.
No questions yet.

Cerdas Inovasi Digital Team
Software developers, BIM & 3D engineers, and AI practitioners
We build software, BIM models, games and AI automations for clients every day, and turn that hands-on work into step-by-step classes: every step is shown on screen and comes with a PDF guide you can keep.
See our clients →