<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Elif Zeynep Elverişli on Medium]]></title>
        <description><![CDATA[Stories by Elif Zeynep Elverişli on Medium]]></description>
        <link>https://medium.com/@ezeynepel?source=rss-4316dafa7a02------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*BwcKx1U0OQ-9zYYx</url>
            <title>Stories by Elif Zeynep Elverişli on Medium</title>
            <link>https://medium.com/@ezeynepel?source=rss-4316dafa7a02------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 07:09:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ezeynepel/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Does Adding Attention Always Improve the Model? A U-Net Comparison on the BUSI Dataset]]></title>
            <link>https://medium.com/@ezeynepel/does-adding-attention-always-improve-the-model-a-u-net-comparison-on-the-busi-dataset-0769c098be2f?source=rss-4316dafa7a02------2</link>
            <guid isPermaLink="false">https://medium.com/p/0769c098be2f</guid>
            <category><![CDATA[image-segmentation]]></category>
            <category><![CDATA[unet]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Elif Zeynep Elverişli]]></dc:creator>
            <pubDate>Wed, 03 Jun 2026 09:47:01 GMT</pubDate>
            <atom:updated>2026-06-03T09:50:37.161Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>“Add an attention mechanism, the model improves” — this idea has become almost a dogma in the deep learning literature. In this project, I decided to question it. The research question is simple but the answer is thought-provoking: <strong>Do different attention mechanisms actually improve U-Net’s performance on breast ultrasound image segmentation, and which one works better?</strong></p><p>I tried to answer this by comparing three architectures on the BUSI (Breast Ultrasound Images) dataset: a pure Baseline U-Net, a U-Net with SE Block, and a U-Net with CBAM.</p><p>The result? Unexpected, honest, and instructive.</p><h3>The Problem: Why Is Breast Ultrasound Segmentation Hard?</h3><p>Ultrasound imaging is widely used in the early detection of breast cancer. However, ultrasound images present a particularly challenging domain for segmentation compared to other modalities:</p><ul><li><strong>Low contrast:</strong> The boundary between tumor tissue and surrounding tissue is often ambiguous.</li><li><strong>Speckle noise:</strong> This noise, arising from the physical nature of ultrasound, makes edge detection difficult.</li><li><strong>Shape diversity:</strong> Benign and malignant lesions can have very different morphologies.</li></ul><p>These challenges require the model to learn lesion-specific details rather than just general features — precisely the kind of domain where attention mechanisms could theoretically make a meaningful contribution.</p><h3>Why I Chose This Project?</h3><p>The goal of the assignment was not simply to train a model but to understand and modify an existing architecture.</p><p>I selected U-Net because it is one of the most influential medical image segmentation architectures and provides a clear opportunity for architectural experimentation through attention mechanisms.</p><h3>Dataset: BUSI</h3><p>The BUSI dataset consists of breast ultrasound images and their corresponding segmentation masks. It contains three classes: normal, benign, and malignant.</p><p>In this project, <strong>I deliberately excluded the normal class.</strong> Normal images contain no lesion to segment, so they produce no meaningful training signal for a segmentation model. Working only with benign and malignant images allows the model to focus on learning real lesions.</p><pre># prepare_busi.py<br>CLASSES = [&quot;benign&quot;, &quot;malignant&quot;]  # normal class intentionally excluded</pre><pre>for image_path in class_dir.glob(&quot;*.png&quot;):<br>    if &quot;_mask&quot; in image_path.stem:<br>        continue<br>    mask_path = image_path.with_name(f&quot;{image_path.stem}_mask.png&quot;)<br>    if not mask_path.exists():<br>        skipped_count += 1<br>        continue</pre><p>This filtering resulted in <strong>647 image-mask pairs</strong>. I used a 90%/10% train/validation split: 583 training and 64 validation examples.</p><h3>Architecture: Three Models from One Parameter</h3><p>One of the most elegant aspects of this project is that three different models are produced from the exact same codebase with a single parameter difference. The attention_type parameter takes None, &quot;se&quot;, or &quot;cbam&quot; to shape the model.</p><h3>Baseline U-Net</h3><p>U-Net, with its encoder-decoder structure and skip connections, has become the de facto standard for medical image segmentation. The encoder progressively compresses spatial information while learning semantic features. The decoder uses these features to produce pixel-wise predictions. Skip connections directly transfer fine details from the encoder to the decoder, preserving spatial precision.</p><pre># unet_model.py — forward pass<br>def forward(self, x):<br>    x1 = self.inc(x)       # 64 channels<br>    x2 = self.down1(x1)    # 128 channels<br>    x3 = self.down2(x2)    # 256 channels<br>    x4 = self.down3(x3)    # 512 channels<br>    x5 = self.down4(x4)    # 1024 channels — bottleneck</pre><pre>    x = self.up1(x5, x4)   # decoder begins with skip connection<br>    x = self.up2(x, x3)<br>    x = self.up3(x, x2)<br>    x = self.up4(x, x1)<br>    return self.outc(x)</pre><h3>SE Block — Channel Attention</h3><p>The SE (Squeeze-and-Excitation) Block learns how important each feature map channel is. It first “squeezes” each channel to a single scalar via global average pooling. Then, through two fully connected layers, it produces a weight score for each channel (excitation). These scores are multiplied with the original feature map — unimportant channels are suppressed, important ones are amplified.</p><pre># unet_parts.py — SEBlock<br>def forward(self, x):<br>    b, c, _, _ = x.size()<br>    # Squeeze each channel to a single value<br>    y = self.avg_pool(x).view(b, c)<br>    # Learn channel importance scores<br>    y = self.fc(y).view(b, c, 1, 1)<br>    # Reweight the original feature map<br>    return x * y</pre><p>SE Block only asks the “what” question: which channels matter?</p><h3>CBAM — Channel + Spatial Attention</h3><p>CBAM (Convolutional Block Attention Module) goes one step further than SE Block. It first applies channel attention — similar to SE but using both average and max pooling for a richer information source. Then it applies spatial attention: “where” are the important regions?</p><pre># unet_parts.py — CBAMBlock<br>def forward(self, x):<br>    x = self.channel_attention(x)   # Which channels? (SE-like)<br>    x = self.spatial_attention(x)   # Where? (new dimension)<br>    return x</pre><pre># SpatialAttention<br>def forward(self, x):<br>    avg_out = torch.mean(x, dim=1, keepdim=True)<br>    max_out, _ = torch.max(x, dim=1, keepdim=True)<br>    attention_input = torch.cat([avg_out, max_out], dim=1)<br>    attention = self.sigmoid(self.conv(attention_input))<br>    return x * attention</pre><p>CBAM asks both “what” and “where” — theoretically more comprehensive.</p><h3>Where Is Attention Applied?</h3><p>A critical design decision: attention is applied <strong>on the skip connection</strong> — before passing to the decoder, on the features coming from the encoder.</p><pre># unet_parts.py — Up.forward()<br>def forward(self, x1, x2):<br>    x1 = self.up(x1)           # decoder feature is upsampled<br>    # ...padding...<br>    x2 = self.attention(x2)    # encoder skip connection passes through attention<br>    x = torch.cat([x2, x1], dim=1)<br>    return self.conv(x)</pre><p>This way, the decoder receives the encoder’s information already filtered.</p><h3>Training Configuration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*jt33lNet95acfdH0LlI0qw.png" /></figure><p>Parameter Value Optimizer RMSprop Learning rate 1e-5 Loss function BCEWithLogitsLoss + Dice Loss Batch size 1 Image scale 0.5 Device CPU Epochs (SE, CBAM) 7 Epochs (Baseline) 7 (split as 3+4 from checkpoint)</p><p>I used a combination of BCEWithLogitsLoss and Dice Loss. BCE computes pixel-wise error, while Dice Loss directly optimizes segmentation quality — using both together provides more balanced training.</p><h3>Problems I Encountered</h3><p>This section is perhaps the most instructive.</p><h3>1. The --attention Argument Didn&#39;t Exist</h3><p>On my first attempt to train the SE model, I was greeted with:</p><pre>train.py: error: unrecognized arguments: --attention se</pre><p>The Pytorch-UNet repository I was using didn’t support the attention_type parameter. I had to add the argument parser and model instantiation myself. This is the kind of change that can only be made by truly understanding the code — and it aligns perfectly with the goal of this project.</p><h3>2. SE Block’s First Crash</h3><p>After adding the --attention argument and running the SE model for the first time, the model crashed around image 110. This wasn&#39;t just a manual interrupt — it was a stall in an unstable training process running on CPU. Witnessing this directly gave me the opportunity to observe how the model behaves differently with attention layers.</p><h3>3. Training on CPU — A Real Constraint</h3><p>All training was done on CPU. Each epoch takes approximately <strong>27–32 minutes</strong>. This means:</p><ul><li>Hyperparameter search is practically impossible</li><li>Running more epochs is not feasible</li><li>Batch size must stay at 1</li></ul><p>This constraint is the real answer to “why so few epochs?” With GPU access in an academic setting, the results could have been far more comprehensive.</p><h3>4. Training Instability</h3><p>Perhaps the most unexpected observation. Validation Dice scores showed large fluctuations both within epochs and across epochs. For example, in the SE model:</p><ul><li>Epoch 3, at 79%: <strong>0.513</strong></li><li>Epoch 4, at 18%: <strong>0.413</strong></li><li>Epoch 5, at 97%: <strong>0.411</strong></li></ul><p>This fluctuation stems from high gradient variance caused by the combination of a small dataset, low learning rate, and batch size of 1. A ReduceLROnPlateau scheduler is in place, but the inconsistency in Dice scores also makes it unclear when the scheduler should actually intervene.</p><h3>Results</h3><p>The highest validation Dice score observed across all epochs for each model:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*02EX1hF_3cZPsShaMTTrHw.png" /></figure><p>Model Best Validation Dice Baseline U-Net 0.5341 U-Net + CBAM 0.5203 U-Net + SE 0.5132</p><p>Baseline reaches the highest point. But this table alone can be misleading.</p><p><strong>Important context:</strong> These peak values are mid-epoch measurements — not stable end-of-epoch values. All models fluctuate within a similar band (0.41–0.53), and none is consistently superior to the others. Baseline’s “win” may partly be due to its longer total training time (7 epochs, resumed from checkpoint).</p><p><strong>The real question is:</strong> Does adding attention make a meaningful difference under these constraints? The honest answer: not clearly — but this doesn’t mean attention doesn’t work. It means these experimental conditions weren’t sufficient to reveal the difference.</p><h3>What I Learned</h3><p><strong>Attention is beautiful in theory, context-dependent in practice.</strong> Papers showing the superiority of SE and CBAM typically work on GPUs with far more epochs and augmentation. Under those conditions, the difference is meaningful. With CPU + 7 epochs + batch size 1, measuring the difference between models is statistically unreliable.</p><p><strong>Where you place attention matters.</strong> Applying attention to the skip connection was a deliberate choice — filtering encoder features before they reach the decoder. Whether alternative placements (applying to the bottleneck, adding after each DoubleConv) would change the results is worth exploring.</p><p><strong>Honest reporting matters.</strong> Instead of saying “CBAM achieved the highest score,” reporting what happened across the entire training trajectory reveals the true value of the research.</p><h3>Future Work</h3><p>Several natural next steps exist for extending this project:</p><ul><li><strong>Retraining with GPU</strong> — Repeating the same experiment in a GPU environment with more epochs and augmentation could measure the true effect of attention mechanisms.</li><li><strong>Attention map visualization</strong> — Visualizing what the model “looks at” via grad-CAM or attention map outputs provides understanding beyond numerical metrics.</li><li><strong>Anomaly detection integration</strong> — Since I previously worked on anomaly detection using Isolation Forest-based approaches, an interesting future direction would be combining segmentation and anomaly detection in a unified pipeline. Adding an Isolation Forest-based anomaly detection layer to the segmentation pipeline could be used to pre-filter suspicious regions.</li><li><strong>Weighted loss for class imbalance</strong> — Explicitly addressing the benign/malignant imbalance in the loss function.</li></ul><p><em>Code is available on </em><a href="https://github.com/ezeynepel/Tumor-Segmentation-using-U-Net"><em>GitHub</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0769c098be2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Machine Learning]]></title>
            <link>https://medium.com/@ezeynepel/introduction-to-machine-learning-078f4e1fdd2e?source=rss-4316dafa7a02------2</link>
            <guid isPermaLink="false">https://medium.com/p/078f4e1fdd2e</guid>
            <category><![CDATA[intro]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[supervised-learning]]></category>
            <category><![CDATA[unsupervised-learning]]></category>
            <dc:creator><![CDATA[Elif Zeynep Elverişli]]></dc:creator>
            <pubDate>Sun, 09 Feb 2025 10:31:52 GMT</pubDate>
            <atom:updated>2025-02-09T10:31:52.871Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine Learning (ML) is a subset of Artificial Intelligence (AI) that enables computers to make decisions without being explicitly programmed. By analyzing past data, machine learning algorithms can solve problems or make predictions on new data without requiring manual programming, leading to better decisions in an optimized time.</p><blockquote>Machine learning is essential because:</blockquote><p>⇒It can solve complex business problems by learning from examples or making predictions instead of relying on traditional methods.<br>⇒It works efficiently with large datasets.<br>⇒It can identify repetitive tasks, reducing time consumption and optimizing data processing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9KT3ryJfnFtZxOoFA5XRtQ.jpeg" /></figure><p><strong>Classification of Machine Learning</strong></p><p>Machine learning operates through Supervised Learning and Unsupervised Learning as its main operational categories. Additionally, Reinforcement Learning and Semi-Supervised Learning are also significant subcategories.</p><h3>Supervised Learning</h3><p>As the name suggests, supervised learning has a “supervisor” or a “teacher.” The model learns from labeled data, mapping inputs to outputs by learning a function from labeled examples.</p><p>For instance: The system receives labeled cat photographs for training then it identifies and categorizes new cat pictures. The weather prediction models take advantage of past weather data that has been labeled to produce forecasts of future conditions. The Turkish health platform “e-Nabız” assesses heart attack risks based on past medical history, hospital visits, and family history.</p><p><strong>Types of Supervised Learning</strong></p><ul><li><strong>Classification:</strong> Groups similar items into predefined categories. An algorithm works by grouping fruits into apples or pears by processing previously labeled data.</li><li><strong>Regression:</strong> Predicts numerical outputs. Database models exist to predict house prices according to economic indicators or to evaluate heart attack risks through medical data analysis.</li><li><strong>Object Detection</strong>: Often used in autonomous vehicles to detect surrounding objects, though it may not be as detailed as classification.</li></ul><p><strong>Evaluating Supervised Learning Models<br></strong>Multiple evaluation metrics help ensure the accuracy and generalizability of supervised learning models. The evaluation metrics for regression models include Mean Squared Error (MSE) together with R-squared. For classification: F1 Score and Confusion Matrix.</p><h3>Unsupervised Learning</h3><p>Unsupervised learning works with unlabeled data. Unlike supervised learning, which has labeled inputs and outputs (e.g., “apple” and “pear”), unsupervised learning identifies patterns and hidden structures in the data without predefined labels. Unsupervised learning shows great value for processing big data while developers predict it will attain higher efficiency in upcoming years.</p><p><strong>Types of Unsupervised Learning</strong></p><ul><li><strong>Clustering</strong>: Groups similar data points together. Items that are more similar to each other are grouped into clusters.</li><li><strong>Association Rule Learning</strong>: Finds relationships between data elements. Example algorithms include <strong>Apriori</strong> and <strong>Eclat</strong>.</li><li><strong>Dimensionality Reduction</strong>: Reduces the number of features in a dataset while preserving important structural information.</li></ul><p>Unsupervised learning is commonly used in recommendation systems. For example, e-commerce platforms suggest related but different products, and streaming services like Netflix and Spotify provide personalized recommendations using unsupervised learning.</p><p><strong>Evaluating Unsupervised Learning Models<br></strong>Unsupervised learning evaluations become difficult because this technique operates without access to labeled training data. Two common metrics known as Silhouette Score and Calinski-Harabasz Index help professionals evaluate models for their effectiveness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fL_xycATwARzHHHadfxU3w.jpeg" /></figure><p><strong>Conclusion <br></strong>Both Supervised and Unsupervised Learning play crucial roles in machine learning, enabling data-driven decision-making across various domains.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=078f4e1fdd2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>