<?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 DavudGurbanov on Medium]]></title>
        <description><![CDATA[Stories by DavudGurbanov on Medium]]></description>
        <link>https://medium.com/@qdavud395?source=rss-7162bb5b9a0a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*QEOQOuPkT6p4baMn</url>
            <title>Stories by DavudGurbanov on Medium</title>
            <link>https://medium.com/@qdavud395?source=rss-7162bb5b9a0a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 12:58:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@qdavud395/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[How to perform Automated Data Augmentation]]></title>
            <link>https://medium.com/@qdavud395/how-to-perform-automated-data-augmentation-553c425668b1?source=rss-7162bb5b9a0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/553c425668b1</guid>
            <dc:creator><![CDATA[DavudGurbanov]]></dc:creator>
            <pubDate>Sun, 26 Apr 2026 19:48:42 GMT</pubDate>
            <atom:updated>2026-04-26T19:48:42.504Z</atom:updated>
            <content:encoded><![CDATA[<p>placeholder</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=553c425668b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Time Series Forecasting]]></title>
            <link>https://medium.com/@qdavud395/introduction-to-time-series-forecasting-09ec9b3110dd?source=rss-7162bb5b9a0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/09ec9b3110dd</guid>
            <dc:creator><![CDATA[DavudGurbanov]]></dc:creator>
            <pubDate>Sun, 01 Feb 2026 20:14:05 GMT</pubDate>
            <atom:updated>2026-02-01T20:14:05.085Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zyQU5i6WBpr8TOrQR3T-pw.png" /></figure><p>Everyone wants to know how to make money with Bitcoin! While predicting BTC prices with certainty is impossible, time series forecasting allows us to make educated predictions based on historical data. In this post, I’ll walk you through my process for building an LSTM-based Bitcoin price forecasting model, from data preprocessing to model evaluation.</p><h3>Introduction to Time Series Forecasting</h3><p>Time series forecasting involves predicting future values of a sequence based on past observations. Unlike standard regression tasks, time series data has temporal dependencies, meaning the order of data matters. For Bitcoin, this is crucia-price movements often depend on previous trends, market volatility, and trading volume.</p><p>Recurrent Neural Networks (RNNs), and especially Long Short-Term Memory (LSTM) networks, are well-suited for this task. LSTMs can capture long-term dependencies in sequential data, making them ideal for forecasting Bitcoin prices over time.</p><h3>Data Preprocessing</h3><p>The first step was preparing clean, normalized data for modeling. I worked with Bitcoin price data from <strong>Coinbase</strong> and <strong>Bitstamp</strong>, focusing on the following features:</p><ul><li>Open, High, Low, Close prices</li><li>Trading Volume (BTC)</li></ul><p>Here’s the preprocessing pipeline I followed:</p><ol><li><strong>Loading the data:</strong> I loaded both Coinbase and Bitstamp CSV datasets. If both were available, I merged them on timestamps and averaged overlapping prices. Volume was summed, as it represents market liquidity.</li><li><strong>Handling missing values:</strong> I removed rows with NaN values and performed forward-filling to ensure continuity in the time series.</li><li><strong>Sorting &amp; deduplication:</strong> Data was sorted chronologically and duplicate timestamps were removed.</li><li><strong>Normalization:</strong> I applied min-max normalization to scale features between 0 and 1. This step is crucial for stable training of neural networks. I also saved the min and max values for each feature to allow denormalization later.</li></ol><p>By preprocessing carefully, the model could focus on patterns rather than being affected by missing values or varying scales across features.</p><h3>Setting Up tf.data.Dataset for Model Inputs</h3><p>Neural networks require fixed-size inputs, so I converted the time series into sequences using a sliding window approach:</p><ul><li><strong>Lookback period:</strong> 24 hours of historical data, sampled every minute (1440 timesteps)</li><li><strong>Target variable:</strong> The Close price at the next timestep</li></ul><p>For example, to predict the Close price at time <em>t</em>, the model uses the prices and volume from the previous 1440 minutes as input.</p><p>I then split the data into <strong>training</strong> and <strong>validation sets</strong> and created TensorFlow datasets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*mRBoqg0tgn-w9iqTWtd11Q.png" /></figure><p>This setup ensures efficient batching and shuffling during training, improving convergence.</p><h3>Model Architecture</h3><p>I chose an <strong>LSTM-based RNN</strong> for forecasting. The architecture:</p><ol><li><strong>First LSTM layer (64 units, return sequences):</strong> Captures temporal patterns across all timesteps.</li><li><strong>Dropout (0.2):</strong> Prevents overfitting.</li><li><strong>Second LSTM layer (32 units):</strong> Refines the learned temporal features.</li><li><strong>Dense layers:</strong> Adds non-linear transformations for better predictions.</li><li><strong>Output layer:</strong> Single neuron predicting the next Close price.</li></ol><p>I compiled the model using <strong>Mean Squared Error (MSE)</strong> as the loss function and <strong>Adam optimizer</strong>, which works well for time series tasks.</p><h3>Results</h3><p>After training the model for up to 50 epochs with early stopping, here are the evaluation metrics on the validation set:</p><ul><li><strong>Validation MSE:</strong> ~0.0002 (normalized)</li><li><strong>Validation MAE:</strong> ~0.012 (normalized)</li><li><strong>Denormalized MAE:</strong> ~$48.50</li></ul><h3>Conclusion</h3><p>Building this BTC forecasting model was an insightful experience. While predicting exact Bitcoin prices is extremely challenging due to market volatility, LSTM networks allow us to model short-term trends and provide reasonable forecasts.</p><p>Key takeaways:</p><ul><li>Preprocessing and normalization are critical for time series modeling.</li><li>LSTMs are effective at capturing temporal dependencies in financial data.</li><li>Forecasting BTC can provide guidance for trading strategies, but caution is always required.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=09ec9b3110dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bayesian Optimization of a Neural Network Using Gaussian Processes]]></title>
            <link>https://medium.com/@qdavud395/bayesian-optimization-of-a-neural-network-using-gaussian-processes-dda18ebe2778?source=rss-7162bb5b9a0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/dda18ebe2778</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[DavudGurbanov]]></dc:creator>
            <pubDate>Sun, 14 Dec 2025 13:17:04 GMT</pubDate>
            <atom:updated>2025-12-14T13:17:04.984Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ktK4RKHnl20UK47Yb-CDpQ.png" /></figure><h3><strong>Introduction</strong></h3><p>Hyperparameter tuning is one of the most important yet expensive steps in machine learning. Traditional methods such as grid search or random search often require a large number of evaluations and do not efficiently use information from previous trials.</p><p>In this post, I explore how <strong>Bayesian Optimization</strong>, powered by <strong>Gaussian Processes</strong>, can efficiently optimize the hyperparameters of a neural network trained on the MNIST dataset.</p><h3>What is a Gaussian Process?</h3><p>A <strong>Gaussian Process (GP)</strong> is a probabilistic model that defines a distribution over functions. Instead of predicting a single output value, a Gaussian Process provides a <strong>mean prediction and an uncertainty estimate</strong> for every input point.</p><p>In this project, the Gaussian Process is used as a <strong>surrogate model</strong>: it approximates the behavior of the true objective function (validation accuracy as a function of hyperparameters) while quantifying uncertainty. This uncertainty plays a crucial role in deciding where to sample next.</p><h3>What is Bayesian Optimization?</h3><p><strong>Bayesian Optimization</strong> is an optimization strategy designed for expensive black-box functions. It works by iteratively:</p><ol><li><strong>Modeling the objective function using a Gaussian Process</strong></li><li><strong>Using an acquisition function to balance exploration and exploitation</strong></li><li><strong>Selecting the next hyperparameter configuration to evaluate</strong></li><li><strong>Updating the model with the new observation</strong></li></ol><p>This approach allows the optimizer to find good solutions with <strong>far fewer evaluations</strong> than exhaustive search methods.</p><h3>Model Chosen</h3><p>The model optimized in this experiment is a <strong>fully connected neural network (MLP)</strong> implemented using TensorFlow and Keras.</p><p>The network consists of:</p><ul><li><strong>One hidden dense layer with ReLU activation</strong></li><li><strong>Dropout for regularization</strong></li><li><strong>A softmax output layer for classification</strong></li></ul><p>The model was trained on the <strong>MNIST handwritten digits dataset</strong>, using validation accuracy as the optimization target.</p><h3>Hyperparameters Optimized:</h3><p>The following hyperparameters were optimized using Bayesian Optimization:</p><ol><li><strong>Learning rate</strong></li><li><strong>Number of hidden units</strong></li><li><strong>Dropout rate</strong></li><li><strong>L2 regularization weight</strong></li><li><strong>Batch size</strong></li></ol><h3>Why These Hyperparameters?</h3><p>These hyperparameters were chosen because they have a strong influence on both model performance and generalization:</p><ul><li>The <strong>learning rate</strong> controls convergence speed and stability</li><li>The <strong>number of units</strong> determines model capacity</li><li><strong>Dropout</strong> and <strong>L2 regularization</strong> help prevent overfitting</li><li><strong>Batch size</strong> affects gradient estimation and training dynamics</li></ul><p>Optimizing these parameters jointly allows the model to achieve better performance while remaining robust.</p><h3>Satisficing Metric</h3><p>The chosen satisficing metric for optimization was <strong>validation accuracy</strong>.</p><p>Validation accuracy directly reflects the model’s ability to generalize to unseen data, which is the ultimate goal for classification tasks. Since Bayesian Optimization minimizes an objective function, the negative validation accuracy was used internally.</p><h3>Optimization Process &amp; Results</h3><p>Bayesian Optimization was run for a maximum of <strong>30 iterations</strong>, with early stopping applied during each training session to avoid overfitting.</p><p>During each iteration:</p><ul><li><strong>The model saved a checkpoint of the best-performing epoch</strong></li><li><strong>The checkpoint filename encoded the hyperparameter values</strong></li></ul><p>After optimization, the best validation accuracy achieved was <strong>96.79%</strong>, with the following hyperparameters:</p><ul><li><strong>Learning rate: 0.01</strong></li><li><strong>Hidden units: 128</strong></li><li><strong>Dropout: 0.5</strong></li><li><strong>L2 weight: 1e-6</strong></li><li><strong>Batch size: 64</strong></li></ul><h3>Convergence Plot</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*heyluyNQhuTgnpu1FbjJNw.png" /></figure><p>The convergence plot illustrates two key behaviors:</p><ul><li><strong>A monotonic improvement in the best validation accuracy over iterations</strong></li><li><strong>A decreasing distance between consecutive hyperparameter samples</strong></li></ul><p>This behavior demonstrates a successful transition from <strong>exploration</strong> in early iterations to <strong>exploitation</strong> in later iterations, which is characteristic of effective Bayesian Optimization</p><h3>Conclusions &amp; Final Thoughts</h3><p>This experiment demonstrates that Bayesian Optimization is a powerful and sample-efficient approach for hyperparameter tuning. By leveraging uncertainty through Gaussian Processes, the optimizer was able to discover strong hyperparameter configurations in relatively few evaluations.</p><p>In future work, this approach could be extended to deeper architectures, convolutional networks, or multi-objective optimization scenarios.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dda18ebe2778" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Achieving High CIFAR-10 Accuracy with Transfer Learning: From MobileNetV2 to EfficientNetB0]]></title>
            <link>https://medium.com/@qdavud395/achieving-high-cifar-10-accuracy-with-transfer-learning-from-mobilenetv2-to-efficientnetb0-54b143efa024?source=rss-7162bb5b9a0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/54b143efa024</guid>
            <dc:creator><![CDATA[DavudGurbanov]]></dc:creator>
            <pubDate>Sun, 19 Oct 2025 19:46:33 GMT</pubDate>
            <atom:updated>2025-10-19T19:46:33.243Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*TfOifjsoTx6DMnoU.png" /></figure><h3>Abstract</h3><p>In this study, I explored transfer learning techniques to classify the CIFAR-10 dataset. Initially, MobileNetV2 achieved 85% test accuracy. ResNet50 was attempted but failed to converge, reaching only 15–20% accuracy. Finally, EfficientNetB0 successfully achieved 94% test accuracy after fine-tuning with data augmentation. This work demonstrates the importance of selecting an appropriate pre-trained architecture for small image datasets.</p><h3>Introduction</h3><p>Image classification on CIFAR-10 remains a benchmark problem in deep learning due to the dataset’s small images (32×32 pixels) and 10 classes. Transfer learning allows leveraging pre-trained convolutional neural networks trained on large datasets, such as ImageNet, to improve performance on smaller datasets. However, choosing the right architecture is critical, as some models do not adapt well to low-resolution data.</p><p>The main problem addressed in this study was: <strong>how to achieve high classification accuracy on CIFAR-10 using transfer learning while avoiding convergence issues</strong>.</p><h3>Materials and Methods</h3><p><strong>Datasets:</strong> CIFAR-10, consisting of 60,000 32×32 color images in 10 classes, split into 50,000 training and 10,000 test images.</p><p><strong>Software and Libraries:</strong></p><ul><li>Python 3.12</li><li>TensorFlow 2.x / Keras</li><li>NumPy</li></ul><p><strong>Experimental Procedure:</strong></p><ol><li><strong>MobileNetV2 Baseline:</strong></li></ol><ul><li>Resized 32×32 images to 128×128 using a Lambda layer.</li><li>Added top layers: Dense 256 → Dense 128 → Softmax.</li><li>Trained using Adam optimizer with categorical cross-entropy loss.</li><li>Achieved <strong>85% test accuracy</strong>.</li></ul><ol><li><strong>ResNet50 Attempt:</strong></li></ol><ul><li>Similar resizing and top layer structure.</li><li>Model did not converge; training stuck at 15–20% accuracy in the first epochs.</li><li>Likely due to ResNet50 being over-parameterized for small images and limited data.</li></ul><ol><li><strong>EfficientNetB0 Final Model:</strong></li></ol><ul><li>Resized images to 224×224.</li><li>Added custom top layers with dropout and batch normalization.</li><li>Used two-phase training: feature extraction (frozen base) followed by fine-tuning last layers.</li><li>Applied data augmentation: flips, rotations, zooms, and translations.</li><li>Achieved <strong>94% test accuracy</strong>.</li></ul><p>Example Code Snippet (EfficientNetB0 Lambda Layer):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*zZG1rcyWaglGG5W0nq5xzw.png" /></figure><h3>Results</h3><p><strong>Model Performance on CIFAR-10:</strong></p><p><strong>MobileNetV2</strong></p><ul><li>Test Accuracy: 85%</li><li>Notes: Baseline model, good performance but not optimal</li></ul><p><strong>ResNet50</strong></p><ul><li>Test Accuracy: 15–20%</li><li>Notes: Failed to converge, stuck in early epochs</li></ul><p><strong>EfficientNetB0</strong></p><ul><li>Test Accuracy: 94%</li><li>Notes: High-performing final model, best results</li></ul><p><strong>Observations:</strong></p><ul><li>MobileNetV2 performed reasonably well but was not optimal.</li><li>ResNet50 struggled due to mismatch between model capacity and dataset size.</li><li>EfficientNetB0 successfully leveraged pre-trained weights, and the resizing + data augmentation strategy significantly improved accuracy.</li></ul><h3>Discussion</h3><p>The experiments highlight several key points:</p><ol><li><strong>Model selection matters:</strong> Over-parameterized networks like ResNet50 can fail on small datasets.</li><li><strong>Input size adaptation:</strong> EfficientNetB0 requires 224×224 input, making Lambda resizing essential.</li><li><strong>Data augmentation and fine-tuning:</strong> Critical to improve generalization on CIFAR-10.</li></ol><p>This process demonstrates the iterative nature of deep learning experiments and the importance of adapting architectures to dataset characteristics.</p><h3>Literature Cited</h3><ol><li>Tan, M., &amp; Le, Q. V. (2019). <em>EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks.</em> arXiv:1905.11946.</li><li>Howard, A. G., et al. (2017). <em>MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications.</em> arXiv:1704.04861.</li><li>He, K., et al. (2016). <em>Deep Residual Learning for Image Recognition.</em> CVPR.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54b143efa024" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ImageNet Classification with Deep Convolutional Neural Networks]]></title>
            <link>https://medium.com/@qdavud395/imagenet-classification-with-deep-convolutional-neural-networks-c745c81e0f39?source=rss-7162bb5b9a0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c745c81e0f39</guid>
            <dc:creator><![CDATA[DavudGurbanov]]></dc:creator>
            <pubDate>Sun, 05 Oct 2025 18:01:14 GMT</pubDate>
            <atom:updated>2025-10-05T18:01:14.209Z</atom:updated>
            <content:encoded><![CDATA[<img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c745c81e0f39" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Neural Network Regularization: Techniques to Prevent Overfitting]]></title>
            <link>https://medium.com/@qdavud395/mastering-neural-network-regularization-techniques-to-prevent-overfitting-85c7f210629b?source=rss-7162bb5b9a0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/85c7f210629b</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[DavudGurbanov]]></dc:creator>
            <pubDate>Sun, 21 Sep 2025 18:55:30 GMT</pubDate>
            <atom:updated>2025-09-21T18:55:30.873Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yivJdmKAvhercFU9ftGJHg.png" /></figure><h3>Overview</h3><p>Training deep neural networks can lead to <strong>overfitting</strong>, where a model performs well on training data but poorly on unseen data. <strong>Regularization</strong> is a set of techniques to prevent overfitting and improve generalization.</p><p>In this blog, we’ll cover:</p><ol><li><strong>L1 Regularization</strong></li><li><strong>L2 Regularization</strong></li><li><strong>Dropout</strong></li><li><strong>Data Augmentation</strong></li><li><strong>Early Stopping</strong></li></ol><p>For each technique, we’ll discuss <strong>what it is, how it works, its pros and cons</strong>, and include <strong>examples with formulas</strong>.</p><h3>1. L1 Regularization</h3><p><strong>Definition:</strong><br> L1 regularization, also known as <strong>Lasso</strong>, adds a penalty equal to the <strong>absolute value of the weights</strong> to the loss function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*bkziy3PzKR8AEdEGoBhA1w.png" /></figure><ul><li>w_i​ = weight of feature i</li><li>λ = regularization strength</li></ul><p><strong>When to use:</strong></p><ul><li>Useful when you want <strong>sparse models</strong> (many weights become exactly zero).</li><li>Great for <strong>feature selection</strong>.</li></ul><p><strong>When not to use:</strong></p><ul><li>If you need small weights but not necessarily zeros (L2 is better).</li><li>For highly correlated features, L1 can behave unpredictably.</li></ul><p><strong>Pros:</strong></p><ul><li>Produces sparse models → simpler and interpretable.</li><li>Can perform feature selection automatically.</li></ul><p><strong>Cons:</strong></p><ul><li>Might remove important correlated features.</li><li>Can be unstable if features are highly correlated.</li></ul><p><strong>Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*YY1kBV2ebKCmlexr96f4Bw.png" /></figure><h3>2. L2 Regularization</h3><p><strong>Definition:</strong><br> L2 regularization, also called <strong>Ridge</strong>, adds a penalty equal to the <strong>square of the weights</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/193/1*DaZb0tOtt-rZAgQWRYSLuw.png" /></figure><p><strong>Pros:</strong></p><ul><li>Keeps weights small, reducing overfitting.</li><li>Works well when features are highly correlated.</li><li>Smooth penalty → stable optimization.</li></ul><p><strong>Cons:</strong></p><ul><li>Does not produce sparse weights.</li><li>May not remove irrelevant features completely.</li></ul><p><strong>Differences from L1:</strong></p><ul><li>L1 → encourages sparsity (weights can become 0)</li><li>L2 → encourages small weights (weights shrink but rarely reach 0)</li></ul><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*IJowW-2s6cDwYf-PRzZeXQ.png" /></figure><h3>3. Dropout</h3><p><strong>Definition:</strong><br> Dropout randomly <strong>“drops” neurons</strong> during training to prevent co-adaptation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*biSfUZEAMhIGYLMrpOIKsg.png" /></figure><ul><li>a_i​ = activation of neuron i</li><li>p = dropout probability</li></ul><p><strong>Pros:</strong></p><ul><li>Reduces overfitting.</li><li>Works well with other regularization methods.</li><li>Simple to implement.</li></ul><p><strong>Cons:</strong></p><ul><li>Slows down training.</li><li>Requires scaling activations during inference.</li></ul><p><strong>Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*zgKBAzaKGrG3_Mb8sJyZAA.png" /></figure><h3>4. Data Augmentation</h3><p><strong>Definition:</strong><br> Data augmentation artificially <strong>expands the dataset</strong> by applying transformations like rotations, flips, or color changes.</p><p><strong>Pros:</strong></p><ul><li>Reduces overfitting.</li><li>Useful when the dataset is small.</li><li>Can improve model robustness.</li></ul><p><strong>Cons:</strong></p><ul><li>Not all transformations make sense for every dataset.</li></ul><p><strong>Example:</strong></p><ul><li>Rotate images by ±15°, flip horizontally, zoom by 0.9–1.1</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/1*QmhZaNH1uBJ4SAWU4TeB6Q.png" /></figure><h3>5. Early Stopping</h3><p><strong>Definition:</strong><br> Early stopping <strong>halts training</strong> when performance on a validation set stops improving:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/265/1*3v5KuC004DF4Zr1nWdbmKw.png" /></figure><p><strong>Pros:</strong></p><ul><li>Prevents overfitting.</li><li>Simple to implement.</li><li>No modification to loss function required.</li></ul><p><strong>Cons:</strong></p><ul><li>Can stop too early if validation noise is high.</li><li>Requires monitoring a validation set.</li></ul><p><strong>Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*XtfSNTGtz7Tdi77alZd5Vw.png" /></figure><h3><strong>Conclusion</strong></h3><p>Regularization is <strong>essential for building robust neural networks</strong>. L1 and L2 shrink weights, Dropout prevents co-adaptation, Data Augmentation enlarges your dataset, and Early Stopping prevents overfitting during training.</p><p>No single technique fits all scenarios — often, <strong>a combination of these methods</strong> produces the best results. By mastering these strategies, you can train models that <strong>generalize better and perform reliably on unseen data</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85c7f210629b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Neural Network Optimization: From Feature Scaling to Adam]]></title>
            <link>https://medium.com/@qdavud395/mastering-neural-network-optimization-from-feature-scaling-to-adam-7481ee3ebdc4?source=rss-7162bb5b9a0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7481ee3ebdc4</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[mathematics]]></category>
            <dc:creator><![CDATA[DavudGurbanov]]></dc:creator>
            <pubDate>Sun, 14 Sep 2025 17:54:53 GMT</pubDate>
            <atom:updated>2025-09-14T17:54:53.195Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mawEAKQ4TvHEFQ_w_JCtiA.jpeg" /></figure><p>Training neural networks efficiently isn’t just about having lots of data or powerful hardware — it also depends heavily on <strong>how we optimize the learning process</strong>. There are several techniques that make training faster, more stable, and more accurate.</p><p>In this blog, we’ll walk through some of the most widely used optimization techniques in machine learning:</p><ul><li><strong>Feature Scaling</strong> (preprocessing inputs),</li><li><strong>Batch Normalization</strong> (normalizing hidden layers),</li><li><strong>Mini-batch Gradient Descent</strong> (splitting training into chunks),</li><li><strong>Gradient Descent with Momentum</strong> (speeding up convergence),</li><li><strong>RMSProp</strong> and <strong>Adam</strong> (adaptive learning rate optimizers), and</li><li><strong>Learning Rate Decay</strong> (slowing down learning over time).</li></ul><p>Let’s start at the very beginning — preparing the data itself.</p><h3>Feature Scaling</h3><p><strong>Feature scaling</strong> (also called <strong>normalization</strong>) is the process of adjusting the range or distribution of your input features so that they are on a similar scale. This ensures that no single feature dominates the learning process simply because it has larger numerical values.</p><h3>Common Methods</h3><ol><li><strong>Rescaling (Min–Max Normalization)</strong><br> Scales features to a fixed range, often [0,1][0,1][0,1]:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/177/1*Xd_TP72H3Tu0Eh4hpPqEtw.png" /></figure><p><strong>2. Standardization (Z-score Normalization)</strong><br> Centers data around 0 and gives it unit variance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/92/1*2g1uj_Skn3Xk5H_I37EHQQ.png" /></figure><p>where m is the mean and s is the standard deviation of the dataset</p><p><strong>3. Mean Normalization</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/177/1*T28oq7wUZC2-3yt6rN4MXg.png" /></figure><p><strong>4. Unit Length (Vector Normalization)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/73/1*M59kRvAj0E48g3Xh_r3HyA.png" /></figure><h3>Example</h3><pre>import numpy as np<br><br>X = np.array([1, 2, 3], dtype=float)<br><br># Min–Max normalization<br>X_minmax = (X - X.min()) / (X.max() - X.min())  # [0., 0.5, 1.]<br><br># Z-score normalization<br>X_z = (X - X.mean()) / X.std()  # [-1.2247, 0., 1.2247]</pre><h3>Why we need it?</h3><ul><li><strong>Speeds up gradient descent</strong> by making gradients more balanced.</li><li><strong>Some algorithms don’t work at all without scaling</strong> (like k-means, SVM, or neural networks).</li><li><strong>But not all algorithms require it</strong> — tree-based models like decision trees or random forests usually work fine without feature scaling.</li></ul><h3>Batch Normalization</h3><p><strong>Batch Normalization (BatchNorm)</strong> is a technique used to stabilize and accelerate the training of deep neural networks. It works by <strong>standardizing (Z-score normalizing)</strong> the <strong>pre-activated outputs</strong> (the linear outputs before applying the activation function) of each hidden layer.</p><p>During training, for each batch, we calculate the mean and variance of the neurons’ outputs, then normalize them to have <strong>zero mean</strong> and <strong>unit variance</strong>.</p><p>However, strictly forcing them to have zero mean and unit variance could limit what the network can learn.<br> So, BatchNorm introduces two <strong>trainable parameters</strong>:</p><ul><li><strong>γ (gamma):</strong> scales the normalized output</li><li><strong>β (beta):</strong> shifts (offsets) the normalized output</li></ul><p>This lets the model learn the <strong>best distribution</strong> for each layer’s output.</p><h3>How it works (Formulas)</h3><p><strong>Step 1 — Compute mean and variance:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/109/1*OkaOLjPjV0q4x-JUiFrzmA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/171/1*YJjH816dIu66rNg9yMh8fg.png" /></figure><p><strong>Step 2 — Normalize:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/109/1*MhWqDIIfG-hm1JKbtLz4eQ.png" /></figure><p>Step 3 — Scale and shift:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/136/1*Z0MK7o3ZYDc3kO1eWH-9Cg.png" /></figure><p>Here:</p><ul><li>ϵ is a small constant to avoid division by zero</li><li>γ and β are <strong>learned during training</strong></li></ul><h3>Pros of Batch Normalization</h3><ul><li>Works well with other optimizers like <strong>SGD with momentum, RMSProp, and Adam</strong></li><li>Allows training of <strong>deeper networks with shorter training time</strong></li><li><strong>Stable if the batch size is large</strong></li><li><strong>Allows higher learning rates</strong> without diverging</li><li>Adds a <strong>regularizing effect</strong> (can reduce the need for dropout)</li></ul><h3>Cons of Batch Normalization</h3><ul><li><strong>Not good for online learning</strong> (where batches are very small)</li><li><strong>Not ideal for RNNs or LSTMs</strong>, which use sequential data</li><li>Requires <strong>different behavior during training vs testing</strong>, which can make implementation slightly more complex</li></ul><h3>Mini-Batch Gradient Descent (SGD)</h3><p><strong>Mini-Batch Gradient Descent</strong>, often referred to as <strong>Stochastic Gradient Descent (SGD)</strong>, is an optimization technique that lies between <strong>Batch Gradient Descent</strong> and <strong>Stochastic Gradient Descent</strong>.</p><p>Instead of computing the gradients over the <strong>entire dataset</strong> (which can be slow) or over <strong>just one data point</strong> (which can be noisy), mini-batch GD splits the training data into <strong>small batches</strong> of a fixed size.</p><p>For each mini-batch:</p><ol><li>Compute the forward pass</li><li>Compute the gradient via backpropagation</li><li>Update the model parameters</li></ol><p>Completing backpropagation on all mini-batches constitutes <strong>one epoch</strong>. Often, the dataset is <strong>randomly shuffled</strong> at the start of each epoch to improve convergence.</p><h3>How it works (Conceptual Formula)</h3><p>Suppose we have a mini-batch of size bbb from total mmm training samples. For each mini-batch:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*HLMtBojhaMAW_KPBXhmN-w.png" /></figure><p>Where:</p><ul><li>θ = model parameters</li><li>α = learning rate</li><li>L(x_i, y_i) = loss for data point i</li><li>b = mini-batch size</li></ul><h3>Example in Python</h3><pre>import numpy as np<br><br>X = np.arange(20).reshape(10, 2)  # 10 samples, 2 features<br>Y = np.arange(10)                 # 10 labels<br><br>batch_size = 3<br><br>for i in range(0, len(X), batch_size):<br>    X_batch = X[i:i+batch_size]<br>    Y_batch = Y[i:i+batch_size]<br>    print(&quot;Mini-batch X:\n&quot;, X_batch)<br>    print(&quot;Mini-batch Y:\n&quot;, Y_batch)</pre><h3>Pros of Mini-Batch GD</h3><ul><li><strong>Speeds up gradient descent</strong> compared to full-batch GD</li><li><strong>More stable convergence</strong> than pure stochastic GD</li></ul><h3>Cons of Mini-Batch GD</h3><ul><li><strong>Difficult to choose an appropriate batch size</strong></li><li><strong>Hard to deal with saddle points</strong></li><li><strong>Hard to deal with ravines and local optima</strong></li></ul><h3>RMSProp Optimization</h3><p><strong>RMSProp (Root Mean Square Propagation)</strong> is an adaptive learning rate optimization algorithm designed to <strong>speed up convergence</strong> and <strong>handle ravines and saddle points</strong> effectively. It builds on <strong>gradient descent with momentum</strong> but scales each parameter’s update individually based on a moving average of squared gradients.</p><h3>Key Concepts: Saddle Points, Ravines, Local Optima</h3><p>Before diving into formulas:</p><ul><li><strong>Saddle point:</strong> A point in the loss landscape where the gradient is zero, but it’s <strong>not a minimum</strong> (like a mountain pass). Optimization can get stuck here.</li><li><strong>Ravine:</strong> A region where the loss surface curves sharply in one direction and gently in another. Vanilla gradient descent can oscillate or converge slowly.</li><li><strong>Local optimum:</strong> A point that is lower than surrounding points but <strong>not the global minimum</strong>.</li></ul><p>RMSProp helps the optimizer navigate these tricky regions by <strong>adapting learning rates per parameter</strong>.</p><h3>How RMSProp Works (Formulas)</h3><ol><li>Compute a moving average of squared gradients:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*ky_gh4sdP8ZT8LjRY4gYaQ.png" /></figure><p>2. Update parameters using the scaled gradient:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/163/1*TyLHeUbhgOJRRYjhvLY6iw.png" /></figure><p>Where:</p><ul><li>α = learning rate</li><li>β = RMSProp decay rate (momentum-like)</li><li>ϵ = small constant to avoid division by zero</li><li>s_t = moving average of squared gradients</li></ul><p>Notice how the gradient is <strong>divided by the root of its recent variance</strong>, which stabilizes updates in steep directions.</p><h3>Example in Python</h3><pre>import numpy as np<br><br>alpha = 0.01<br>beta = 0.9<br>epsilon = 1e-8<br><br>theta = 1.0<br>grad = 0.2<br>s = 0.0<br><br># RMSProp update<br>s = beta * s + (1 - beta) * grad**2<br>theta = theta - alpha * grad / np.sqrt(s + epsilon)<br><br>print(&quot;Updated parameter:&quot;, theta)</pre><h3>Pros of RMSProp</h3><ul><li><strong>Speeds up gradient descent</strong></li><li><strong>Helps navigate ravines and saddle points</strong></li><li><strong>Can use a larger learning rate</strong></li></ul><h3>Cons of RMSProp</h3><ul><li>Like other adaptive methods, it <strong>may not always reach the global optimum</strong></li><li>Must add a small <strong>epsilon</strong> to prevent division by zero</li></ul><h3>Adam Optimization</h3><p><strong>Adam (Adaptive Moment Estimation)</strong> is an optimization algorithm that <strong>combines the benefits of RMSProp and Gradient Descent with Momentum</strong>. It adapts the learning rate for each parameter individually while also using momentum to accelerate convergence in the right directions.</p><p>Adam keeps track of:</p><ul><li><strong>First moment (mean of gradients):</strong> m_t</li><li><strong>Second moment (uncentered variance of gradients):</strong> v_t</li></ul><p>It also applies <strong>bias correction</strong> to account for initialization at zero.</p><h3>How Adam Works (Formulas)</h3><ol><li><strong>Compute first and second moments:</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/1*FqKIy8inpp5XJHqY1SOPDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*CjsGPXEEMyx7V6VOho_5Lw.png" /></figure><p>2. Bias correction:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/213/1*VCr9Bxgw4O2B_iSfWc5qFA.png" /></figure><p>3. Update parameters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/163/1*HP9DNJQ5oJdfR09FUKC0Hg.png" /></figure><p>Where:</p><ul><li>α = learning rate</li><li>β_1,β_2​ = exponential decay rates for the first and second moments</li><li>ϵ = small constant to prevent division by zero</li></ul><h3>Example in Python</h3><pre>import numpy as np<br><br>alpha = 0.01<br>beta1 = 0.9<br>beta2 = 0.999<br>epsilon = 1e-8<br><br>theta = 1.0<br>grad = 0.2<br>m = 0.0<br>v = 0.0<br>t = 1<br><br># Adam update<br>m = beta1 * m + (1 - beta1) * grad<br>v = beta2 * v + (1 - beta2) * grad**2<br><br>m_hat = m / (1 - beta1**t)<br>v_hat = v / (1 - beta2**t)<br><br>theta = theta - alpha * m_hat / (np.sqrt(v_hat) + epsilon)<br><br>print(&quot;Updated parameter:&quot;, theta)</pre><h3>Pros of Adam</h3><ul><li><strong>Works well with sparse gradients (e.g., NLP, recommendation systems)</strong></li><li><strong>Good for online learning or mini-batches</strong></li><li><strong>Speeds up gradient descent</strong></li><li><strong>Good at navigating ravines and saddle points</strong></li></ul><h3>Cons of Adam</h3><ul><li>Adam <strong>does not always achieve the optimal results</strong> relative to other optimization methods</li><li>Slightly more <strong>memory intensive</strong> than standard gradient descent</li><li>Requires careful tuning of <strong>hyperparameters</strong> (α,β_1,β_2​)</li></ul><h3>Learning Rate Decay</h3><p><strong>Learning Rate Decay</strong> is a technique used to <strong>gradually reduce the learning rate</strong> during training. This helps the optimizer <strong>approach the minimum more carefully</strong>, avoiding overshooting as it gets closer to the optimum.</p><p>The idea is simple: start with a larger learning rate for faster convergence at the beginning, then <strong>slow down updates</strong> as the model nears the optimal point.</p><h3>Common Decay Methods</h3><ol><li><strong>Exponential Decay:</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/106/1*wplD9DPbTrr_VS0v4V045Q.png" /></figure><ul><li>α_0​ = initial learning rate</li><li>d = decay rate</li><li>t = number of epochs or steps</li></ul><p><strong>2. Time-based Decay:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/103/1*0RxUtZDBI39I-Lrc5QiMsQ.png" /></figure><ul><li>Slows learning gradually over time</li></ul><p><strong>3. Step Decay:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/132/1*ke861YblV4Ph4DPWg0-_sg.png" /></figure><ul><li>Reduces learning rate stepwise every t_drop epochs</li></ul><p>By slowing down the learning rate near the minimum, we reduce the chance of <strong>overshooting</strong> and oscillations around the optimum.</p><h3>Example in Python (Step Decay)</h3><pre>alpha_0 = 0.1<br>decay_rate = 0.5<br>decay_step = 10<br><br>for epoch in range(30):<br>    alpha = alpha_0 * (decay_rate ** (epoch // decay_step))<br>    print(f&quot;Epoch {epoch+1}, Learning rate: {alpha}&quot;)</pre><h3>Pros of Learning Rate Decay</h3><ul><li>Helps the optimizer <strong>fine-tune weights near the minimum</strong></li><li><strong>Reduces oscillations</strong> and overshooting</li><li>Can <strong>speed up early training</strong> by using a larger learning rate initially</li></ul><h3>Cons of Learning Rate Decay</h3><ul><li>Many <strong>hyperparameters</strong> to tune (decay rate, step size, etc.)</li><li>Hard to know <strong>when to drop</strong> the learning rate</li><li>Static decay schedules are <strong>not adaptive</strong></li><li>Often better to use <strong>adaptive optimizers</strong> like RMSProp or Adam</li></ul><h3>Conclusion</h3><p>Optimizing neural networks is as much an art as it is a science. The techniques we explored — Feature Scaling, Batch Normalization, Mini-Batch Gradient Descent, Momentum, RMSProp, Adam, and Learning Rate Decay — each tackle different challenges in the training process. There’s no single “best” method; the right choice often depends on your data, model architecture, and training goals.</p><p>The key is to <strong>understand how each method works</strong>, experiment with them, and <strong>combine strategies thoughtfully</strong> to achieve faster convergence and better generalization. As you build more complex models, mastering these optimization tools will help you train more efficiently, avoid common pitfalls, and ultimately build smarter, more robust systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7481ee3ebdc4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>