<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://t-kalv.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://t-kalv.github.io/" rel="alternate" type="text/html" /><updated>2026-03-27T22:36:49+00:00</updated><id>https://t-kalv.github.io/feed.xml</id><title type="html">T.Kalvin’s Homepage</title><subtitle>personal description</subtitle><author><name>Thiruwaran Kalvin</name></author><entry><title type="html">Space-based AI Data Centres</title><link href="https://t-kalv.github.io/posts/2026/03/2026-03-27-SpaceDataCentres/" rel="alternate" type="text/html" title="Space-based AI Data Centres" /><published>2026-03-27T00:00:00+00:00</published><updated>2026-03-27T00:00:00+00:00</updated><id>https://t-kalv.github.io/posts/2026/03/SpaceDataCentres</id><content type="html" xml:base="https://t-kalv.github.io/posts/2026/03/2026-03-27-SpaceDataCentres/"><![CDATA[<p>After taking a deep dive into the computational infrastucture demands of modern Artificial Intelligence, I realised that while our models are scaling exponentially, the physical infrastructure required to run them is hitting a massive bottleneck. We tend to trust and assume that these so called <strong>“Hyperscale”</strong> data centers to process everything from every day user LLM query prompts to Autonomous Vehicle Networks assuming that our current power grids infrastructure can just endlessly accomodates them out of the box.</p>

<p>However, from my research into the hardware side of AI, there seems to be much more of a different truth here where running these enormous Compute Clusters here on Earth is becoming physically and economically unsustainable in the long-term especially as we continue the scale. In this post, I’ll share and summarise my findings on the viability of Space-based AI Data Centres currently.</p>

<h2 id="background">Background</h2>
<h3 id="why-space-based-ai-data-centres">Why Space-based AI Data Centres?</h3>
<p>To a Human, the current modern cloud infrastructure seems like an invisible, infinite storage compute space regardless of where we access it. However, Data Centres operate by consuming massives amount of energy/electricity and generating immense amount of thermal energy (heat) as result of the high-levels of computation. By calculating the physical footprints and energy costs of these models, we can determine mathematically that the Earth’s resouces are a finite boundary. Moving these Data Centres to space creates what is classed as an <strong>Oribital Data Centre</strong>. The goal of these Space-based Orbital Data Centres is to locate an environment that maximises the hardwares’ overall system uptime where the reliance on the Earth’s power grid infrastructure and water cooling is completely eliminated. This ensures that AIs can run on an infinite*, stable energy source (the Sun).</p>

<h2 id="core-ideas">Core Ideas</h2>
<h3 id="the-energy-equation-solar-in-space">The Energy Equation (Solar in Space):</h3>
<p>The core idea of an Oribital Space-based Data Centre is to power the compute units by keeping these satellites in an orbit that is <strong>sun-synchronous</strong>. THis allows for a constant and stable supply of energy from the Sun. Here on Earth, Solar Panels are cheap (lower than <strong>$1 per watt</strong> without taking into account the cost of installation and setup).</p>

<p>Based on recent developments, the base price of space-rated solar panels is around *$11.21 per watt**.</p>

<h3 id="power-consumption-nvidia-hgx-h100-example">Power Consumption (NVIDIA HGX H100) Example:</h3>
<p>A single NVIDIA HGX H100 unit contains 8x H100 GPUs in a single topology. While NVIDIA’s specification sheet lists the power consumptions at <strong>5,600 watts</strong> (5.6kW) and then we approximate the power draw-factoring in the CPU, RAM, SSDs and other necessary components and electronics which results in a total approximation of around <strong>10,000 watts</strong>.</p>

<p>The hardware build price for solar power enery generation is computed as follows:
\(C_{power} = P_{total} \times \text{Cost}_{solar}\)</p>

<p>where:</p>
<ul>
  <li>$P_{total}$: the realistic power consumption (<strong>10,000 watts</strong>)</li>
  <li>$\text{Cost}_{solar}$: the price per watt for space-rated panels (<strong>$11.21</strong>)</li>
  <li>$C_{power}$: The resulting <strong>$112,100</strong> required just to build the solar array for one unit</li>
</ul>

<p>As you can see the hardware build price does seem to be high, but this is nothing in comparison to the launch cost.</p>

<h3 id="launch-cost-spacex-falcon-9-rocket">Launch Cost (SpaceX Falcon 9 Rocket):</h3>
<p>Launch costs are an iterative mathematical problem, where every component adds additional weight and every kilogram adds thousands of dollars extra. Most space solar panel manufacturers converge at an efficiency of approximately <strong>30 watts per kilogram</strong>. Then we need to take into account the weight of the NVIDIA HGX H100 unit which weighs around <strong>24 kg</strong> plus the necessary chassis, cold shields, and other space-specific hardware which results in a total mass of approximately  <strong>100 kg</strong>.</p>

<p>The total payload weight required to sustain the compute module is computed as:</p>

\[W_{total} = \left(\frac{P_{total}}{E_{solar}}\right) + W_{hardware}\]

<p>where:</p>
<ul>
  <li>$E_{solar}$: the energy-to-weight ratio of the panels (<strong>30 W/kg</strong>)</li>
  <li>$W_{hardware}$: the weight of the compute unit and protective chassis (<strong>124 kg</strong>)</li>
  <li>$W_{total}$: the total projected payload weight.</li>
</ul>

<p>Calculating this out, the solar panels alone weigh <strong>333 kg</strong> and when add it to  the <strong>124 kg</strong> compute hardware it results in a massive payload</p>

<h3 id="cooling-in-space-vs-on-earth">Cooling in Space vs on Earth:</h3>
<p>Here on Earth, Data Centres rely on biliions of litres of water and ariflow in order to transfer the heat away from the Servers. However, in Space, a vacuum has no air or water meaning Space-based AI Data Centres must learn to defend against overheating by relying on <strong>Thermal Radiation</strong>. For example, dissipating the heat generated by a 10,000 watt HGX unit requires a radiator roughly the suquare rootage of a medium to large home, which results in even more restrictive mass to the payload.</p>

<h2 id="findings--results">Findings &amp; Results</h2>
<p>If we were launching a HGX H100 unit into orbit using SpaceX’s Falcon 9 (which costs <strong>$2,750 per kilogram</strong>), a clear progression in total costs was observed:</p>
<ul>
  <li><strong>Solar Panel Launch Cost</strong> = 333 kg * $2,750 results in a cost of exactly <strong>$915,750</strong></li>
  <li><strong>Compute Module Launch Cost</strong> = 124 kg * $2,750 results in a cost of exactly <strong>$341,000</strong></li>
  <li><strong>Total Orbital Deployment</strong> = Total launch cost of approximately <strong>$1.3 million</strong> per module.</li>
</ul>

<h2 id="my-takeaways">My Takeaways:</h2>
<p>After researching the viability of Space-based AI Data Centres, it highlighted a fundamental concern in the furutre of AI Data Centres:</p>
<ul>
  <li><strong>Earthly Constraints $\neq$ Infinite Scaling</strong> - We cannot keep building larger models without severely impacting our local power grids and water supplies.</li>
  <li><strong>The Power of Launch Economics</strong> - The current hardware and solar technology is viable. Driving down the $2,750/kg launch cost by a factor of 10 is essential to making orbital data centers a reality.</li>
  <li><strong>Infrastructure is an Arms Race</strong> - As AI models get smarter and even larger, the facilities housing them must evolve beyond simple Eath-based warehouses. We cannot trust our current power grids blindly without considering space-based solutions as an alternative.</li>
</ul>

<h2 id="further-reading--references">Further Reading &amp; References</h2>
<ul>
  <li><strong>Earth Solar Costs:</strong> <a href="https://stacker.com/stories/environment/how-cost-solar-panels-has-fallen">How the cost of solar panels has fallen (Stacker)</a></li>
  <li><strong>Space-Rated Solar Breakthroughs:</strong> <a href="https://www.techbuzz.ai/articles/starpath-slashes-space-solar-costs-90-with-mass-production-push">Starpath slashes space solar costs by 90% (TechBuzz)</a></li>
  <li><strong>NVIDIA HGX H100 Specification</strong> <a href="https://resources.nvidia.com/en-us-hopper-architecture/nvidia-tensor-core-gpu-datasheet">NVIDIA H100 GPU Datasheet</a></li>
  <li><strong>Spacecraft Power Systems:</strong> <a href="https://www.nasa.gov/smallsat-institute/sst-soa/power-subsystems/#3.3">NASA Small Spacecraft Technology - Power Subsystems</a></li>
  <li><strong>Launch Economics:</strong> <a href="https://ourworldindata.org/grapher/cost-space-launches-low-earth-orbit">Cost of Space Launches to Low Earth Orbit (Our World in Data)</a></li>
  <li><strong>Video Breakdown &amp; Math Basis:</strong> <a href="https://www.youtube.com/watch?v=mHKGP5TAxyQ">Space Data Center Explained (YouTube)</a></li>
</ul>]]></content><author><name>Thiruwaran Kalvin</name></author><category term="Space AI Data Centres" /><category term="Space Technology" /><category term="Data Centres" /><category term="GPU" /><category term="Energy" /><category term="Compute" /><category term="Artificial Intelligence" /><summary type="html"><![CDATA[After taking a deep dive into the computational infrastucture demands of modern Artificial Intelligence, I realised that while our models are scaling exponentially, the physical infrastructure required to run them is hitting a massive bottleneck. We tend to trust and assume that these so called “Hyperscale” data centers to process everything from every day user LLM query prompts to Autonomous Vehicle Networks assuming that our current power grids infrastructure can just endlessly accomodates them out of the box.]]></summary></entry><entry><title type="html">Machine Learning Safety</title><link href="https://t-kalv.github.io/posts/2026/01/2026-01-26-MachineLearningSafety/" rel="alternate" type="text/html" title="Machine Learning Safety" /><published>2026-01-26T00:00:00+00:00</published><updated>2026-01-26T00:00:00+00:00</updated><id>https://t-kalv.github.io/posts/2026/01/MachineLearningSafety</id><content type="html" xml:base="https://t-kalv.github.io/posts/2026/01/2026-01-26-MachineLearningSafety/"><![CDATA[<p>After taking an Advanced Artifical Intelligence course, I realised that while modern AI models achieve very highly in terms of benchmark performance, they have a massive, invisible blind spot. We tend to trust these so called <strong>“Black Box”</strong> systems with increasingly critical taks from Self-Driving Vehicles to Autonomous Robotics and Medical Diagnosis - assuming that if they have a high accuracy, they are also “intelligent”.</p>

<p>However, from my experience in participating in an adversarial attack competition revealed a much different truth where these models do not “see the world” that us Humans perceive the world to be (assuming that whoever is reading is that is in-face classified as a Human Being). In this post, I’ll share and summarise my finds on Machine Learning Safety, in particular Adversarial Machine Learning and how I went from simple attacks to breaking state-of-the-art robust defences using techniques such as <strong>FGSM, PGD, Momentum, Input Diversity</strong>…</p>

<h2 id="background">Background</h2>
<p>### 
To a human, an image of a Car looks like a car, regardless of filter, lighting or positioning. However, Neural Networks operate by finding complex mathematical boundaries in a high-dimensional space. By calculating gradients of a model, we can determine mathematically how to modify each pixel in an image to push that image across the boundary.</p>

<p>This modified image of pixels is classes as an Adversarial Example. The goal of an Adversarial Attack is to find a pertubation $\delta$ that maximises the model’s loss where the difference between the original image and modified image is smaller that the <strong>Epsilon limit</strong>, ensuring that the change is invisible to the Human eyes.</p>

<h2 id="core-ideas">Core Ideas:</h2>
<h3 id="fgsm-fast-gradient-sign-method">FGSM (Fast Gradient Sign Method):</h3>
<p>The core idea of FGSM is to modify the original input image by adding a tiny amount of peturbation in the direction that maximally increases the model’s loss. This model takes a <strong>“one-shot”</strong> approach where it takes on single, large step in the direction of the gradient.</p>

<p>It is computed as:
\(x_{adv} = x + \epsilon \cdot \text{sign}(\nabla_x J(\theta, x, y))\)</p>

<p>where:</p>
<ul>
  <li>$\theta$: the model parameters</li>
  <li>$\text{x, y}$: the input and the label</li>
  <li>$J(\theta, x, y)$: the loss function</li>
  <li>A one-step modification to all pixel values to increase the loss function with a ( l_\infty ) perturbation</li>
</ul>

<p>While FGSM is easily blocked if the model’s loss landscape is <strong>non-linear</strong> meaning that one wrong step might result in missing the peak of the curve entirely. FGSM asumers the loss function is entirely linear, but in reality, deep neural networks are highly non-linear. This means that a single, large step is often insufficient to fool a robust model.</p>

<h3 id="pgd-projected-gradient-descent">PGD (Projected Gradient Descent):</h3>
<p>PGD is an interative version of FGSM, where instead of taking one single, large step, we take many small steps ($\alpha $). After each step, if the individual pixel values go beyond the <strong>epislon limit</strong> or the valid pixel range $[0, 1]$, we then <strong>clip/project</strong> the back. This results in the PGD Adversarial Attack’s ability to navigate around <strong>non-linear lines</strong> in the gradient loss landscape in order to find a more accurate adversarial example.</p>

<p>It is computed as:
\(x_{t+1} = \Pi_{x+S} (x_t + \alpha \cdot \text{sign}(\nabla_x J(\theta, x_t, y)))\)</p>

<p>where:</p>
<ul>
  <li>$\alpha$: the step size (learning rate)</li>
  <li>$\Pi$: the projection function (clipping)</li>
  <li>$t$: the current iteration step</li>
</ul>

<p>Standard PGD Adversarial attacks are considered the universal benchmark for evaluation robustness. However, from my experience in participating in an adversarial attack competition, standard PGD struggled to lower the accuracy to aproximately $57 \%$. The adversarial training sample models had learned to defend against standard PGD algorithms due to their use of a <strong>“rugged” defence</strong> which is also known as <strong>Gradient Masking</strong>.</p>

<h3 id="gradient-masking">Gradient Masking:</h3>
<p>Robust models often defend themsef through the creation of “rugged” loss landscaped. They hide their true gradients by creating small, falze local maximas near the data points causing traps for the PGD algorithm to fall into. This resutls in the PGD attack reporting a failure but the model isn’t actuall robust, instead it is just hiding/diverting the path to its failure which is called <strong>Gradient Masking</strong>.</p>

<h3 id="mi-di-fgsm-momentum-plus-input-diversity-fast-gradient-sign-method">MI-DI-FGSM (Momentum plus Input Diversity Fast Gradient Sign Method):</h3>

<h3 id="multi-targetd-pgd-plus-cw-carlini-wagner-loss">Multi-Targetd PGD plus CW (Carlini-Wagner) Loss:</h3>
<p>Standard Adversarial Attack algorithmsa are often untargeted as they just try to maximise the overal gradient loss where they move away from the correct answer. With robust models they are unsure about everything resuling in making it hard for standard Adversarial Attacks to just maximise ther error.</p>

<p>Multi-Target PGD plus CW attempts to push the image towards every other possible workng class. Then it picks the target class that yields the strongesr attack. Then instead of using Standard Cross-Entropy loss as it often relies on probabilities, we instead use a <strong>Carlini-Wagner (CW) loss</strong> where it ignored the probabilites and looks directly at the logits which are the raw scores. It then calculutes the margin between the target class and the correct class.</p>

<p>It is computed as:
\(L(x, t) = \max(Z(x)_{\text{real}} - Z(x)_{\text{target}}, -\kappa)\)</p>

<p>where:</p>

<ul>
  <li>$Z(x)_{\text{real}}$: raw logit score of the correct class</li>
  <li>$Z(x)_{\text{target}}$: raw logit score of the specific target class we want to fake</li>
  <li>$\kappa$: confidence parameter (margin)</li>
</ul>

<p>Through the combination of Multi-Targeting with CW Loss, the Adversarial attack finds the specific vunerability in the models’s Adversarial Training than the standard FGSM/PGD.</p>

<h2 id="findings--results">Findings &amp; Results</h2>
<p>During the evaluation against 9 reference models (ranging from standard to highly robust), it was observed a clear progression in attack sucess:</p>
<ul>
  <li><strong>Standard PGD</strong> = The robust models maintained a high accuracy of around $57 \%$ to $67 \%$</li>
  <li><strong>PGD plus Restarts</strong> = Improved performance slightly, dropping the accuracy down to around $56 \%$</li>
  <li><strong>MI-DI-FGSM and Multi-Targetd PGD plus CW Loss</strong> = Broke defences, resulting in the robust accuracy dopiing significantly to around $30 \%$</li>
</ul>

<h2 id="my-takeaways">My Takeaways:</h2>
<p>After taking an Advanced Artificial Intelligence course and participating in an adversarial attack competition, it highlighted a fudamental concern in Machine Learning Safety</p>
<ul>
  <li><strong>Robustness $\neq$ Correctness:</strong> A model can be robust against simple noise but completely fail against structured/diverse attacks.</li>
  <li><strong>The Power of Randomness:</strong> Deterministic attacks are easy to defend against. Adding stochastic elements like <strong>Input Diversity</strong> is essential to finding the true weaknesses in a model</li>
  <li><strong>Safety is an Arms Race:</strong> As attacks get smarter, defenses must evolve beyond simple adversarial training. We cannot trust a “high accuracy” score blindly without rigorous testing</li>
</ul>

<h2 id="further-reading">Further Reading:</h2>
<ul>
  <li><a href="https://github.com/xiaoweih/AISafetyLectureNotes/blob/main/Machine_Learning_Safety.pdf">Machine Learning Safety: <em>Machine Learning Safetu by Xiawei Huang, Gaojie Jin, Wenjie Ruan</em> </a></li>
  <li><a href="https://robustbench.github.io/">Robust Bench: <em>Standardised benchmark for adversarial robustnedd</em></a></li>
  <li><a href="https://www.researchgate.net/publication/338408111_Adversarial_Attacks_and_Defenses_in_Deep_Learning">Adversarial Attacks and Defenses in Deep Learning: <em>Adversarial Attacks and Defenses in Deep Learning by Kui Ren, Tianhang Zheng, Zhan Qin, Xue Liu</em> </a></li>
</ul>]]></content><author><name>Thiruwaran Kalvin</name></author><category term="Adversarial Attack" /><category term="Adversarial Training" /><category term="Research" /><category term="Artificial Intelligence" /><category term="Machine Learning" /><category term="Deep Learning" /><category term="Machine Learning Safety" /><summary type="html"><![CDATA[After taking an Advanced Artifical Intelligence course, I realised that while modern AI models achieve very highly in terms of benchmark performance, they have a massive, invisible blind spot. We tend to trust these so called “Black Box” systems with increasingly critical taks from Self-Driving Vehicles to Autonomous Robotics and Medical Diagnosis - assuming that if they have a high accuracy, they are also “intelligent”.]]></summary></entry><entry><title type="html">Is Attention Really All You Need?</title><link href="https://t-kalv.github.io/posts/2025/09/2025-09-13-IsAttentionReallyAllYouNeed/" rel="alternate" type="text/html" title="Is Attention Really All You Need?" /><published>2025-09-13T00:00:00+00:00</published><updated>2025-09-13T00:00:00+00:00</updated><id>https://t-kalv.github.io/posts/2025/09/IsAttentionReallyAllYouNeed</id><content type="html" xml:base="https://t-kalv.github.io/posts/2025/09/2025-09-13-IsAttentionReallyAllYouNeed/"><![CDATA[<p>In 2017, Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uzkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin published the Research Paper <strong><em>“Attention Is All You Need”</em></strong>, which introduced the <strong><em>Transformer</em></strong> model architecture, but is Attention really all you need? In this post, I’ll summarise the key ideas in this Research Paper and share my takeaways of whether or not “Is Attention Really All You Need”?</p>

<h2 id="background">Background</h2>
<h3 id="why-transformers">Why Transformers?</h3>
<p>Before 2017 of the introduction of the Transfomer, the majority of sequence-to-sequence models relied on Recurrent Neural Networks (RNN) or Long Short-Term Memories (LSTMs). These models were quite slow and they processed words sequentially, one by one and they often struggled with longer sentences between tokens. This lead to the authors of the paper <em>“Attention Is All You Need</em>, proposing a different approach with an Attention Mechanism.</p>

<p>Attention is a mechanism that Transformers use that allows the model to look at all the words at once and decides how much each word should influence the other. Then it combines the most relevant words to understand meaning, a concept called Self-Attention. This results in a model that captures long-range relationships in text while being much faster/more parallelisable than previous methods such as Recurrent Neural Networks (RNN) or Long Short-Term Memories (LSTMs).</p>

<h2 id="core-ideas">Core Ideas</h2>
<h3 id="self-attention">Self-Attention:</h3>
<p>Instead of processing words sequentially, one by one, the model creates three vectors for each token which are:</p>
<ul>
  <li>Query (Q)</li>
  <li>Key (K)</li>
  <li>Value (V)</li>
</ul>

<p>Then it multiplies the input embedding by the weight matrices that have been previously trained/learned. Next it computes the Attention scores between one token’s Query and the other tokens’ Values to decide how much each word should influence the others. Then a Softmax function is used where the Attention scores are passed through the function to normalise them into probabilities. Then the model uses these probabilities to take the weighted sum of Value Vectors which then produces a new representation for each token that uses the information from the other tokens. This Self Attention mechanism allows the Transformer to work with long-range relationships in the text. This Self-Attention is computed as:
\(\text{Attention}(Q,K,V) = \text{softmax}\!\left(\frac{QK^{T}}{\sqrt{d_k}}\right)V\)
where $K^{T}$ is the transpose of the Key Matrix and $d_k$ is the dimensionality of the Key Vectors.</p>

<h3 id="positional-encoding">Positional Encoding:</h3>
<p>As Transformers process words in parallel instead of sequential, they lose the natural sequential order of the original text which is why the authors introduced Positional Encoding where they introduced adding information about the positions of each of the words in the sequences. The Positional Encoding is computed as:
\(PE_{(pos, 2i)} = \sin\left(\frac{pos}{10000^{2i/d_{model}}}\right), \quad
PE_{(pos, 2i+1)} = \cos\left(\frac{pos}{10000^{2i/d_{model}}}\right)\)
where:</p>
<ul>
  <li>$pos$ is the token position in the sequence</li>
  <li>$i$ is the index dimension</li>
  <li>$d_{model}$ is the embedding size</li>
</ul>

<h3 id="multi-head-attention">Multi-Head Attention:</h3>
<p>Multi-Head Attention which is similar to Self-Attention, allows the model to look at long-range relationships from multiple perspectives simulataneously. Here instead of computing the vectors Query (Q), Key (K), Value (V) as a single set, the Transfomer computes heads of the Query, Key, Value Matrices. Each head has its own learned projection Matrices so that the same input is interpreted in different ways, allowing the model to capture the diverse relationships between the words in the text.</p>

<p>For each head, the attention is computed as:
\(\text{head}_i = \text{Attention}(Q W_i^Q, K W_i^K, V W_i^V)\) 
Then all heads are concatenated and projected:
\(\text{MultiHead}(Q, K, V) = \text{Concat}(\text{head}_1, \dots, \text{head}_h) W^O\)</p>

<h3 id="feed-forward-network-ffn">Feed-Forward Network (FFN):</h3>
<p>After the Attention layers, each Transformer layer has a Feed-Forward Network (FNN) that helps the model transform its representation in a non-linear way. The Feed-Forward Network (FFN) is computed as:</p>

<p>\(\text{Feed-Forward Network}(x) = \text{max}(0, x W_1 + b_1) W_2 + b_2\)
where the weight matrix $W_1$ transforms the input vector.</p>

<h3 id="encoder">Encoder:</h3>
<p>The Encoder stack composes of a stack of $N$ indentical layers where each layer contains a multi-head self-attention sublayer and a position-wise fully connected feed-forward network with residual connections as well as layer normalisation. The output of each sub-layer is computed as:
\(\text{LayerNorm}(x + Sublayer(x))\)</p>

<h3 id="decoder">Decoder:</h3>
<p>The Decoder stack also composes of a stack of N identical layers where it has the same two sub-layers as in each encoder layer except the Decoder has an additional third sub-layer where it peforms multihead attention over the encoder’s output. In addition, the Decoder stack contains a masked multi-head self attention sub-layer that prevents positions from peaking at future tokens instead of the normal multi-head self-attention sub-layer found in the Encoder stack.</p>

<h2 id="transformer-architecture">Transformer Architecture:</h2>
<p><img src="/images/Transformer.svg" alt="Transform Architecture" /></p>

<p><em>Figure 1. Transformer Architecture. Adapted from Vaswani et al. (2017).</em></p>

<h2 id="results">Results:</h2>
<p>The Research Paper <strong><em>“Attention Is All You Need”</em></strong> showed that the <strong><em>Transformer</em></strong> model architecture achieved state-of-the-art results where their model <strong><em>“achieves 28.4 BLEU on the WMT 2014 English-to-German translation task”</em></strong> and on the <strong><em>English-to-French</em></strong> translation task their model achieved a <strong><em>“new state-of-the-art BLEU score of 41.8 after training for 3.5 days on eight GPUs”</em></strong>. This demonstrated that the Transformer architecture can output recurrent and convolutional models while training much faster.</p>

<h2 id="my-takeaways">My Takeaways:</h2>
<p>After reading <strong><em>“Attention Is All You Need”</em></strong>, we can see why the Transfomer plays such a pivotal role in Natural Language Processing (NLP) and Large Language Models (LLM) with having real-world impact in modern applications such as ChatGPT (Decoder-only Transformers), BERT (Encoder-only Transformers), Google Translate (Encoder And Decoder)…</p>

<p>For me, the key takeways were:</p>
<ul>
  <li><strong>Multi-head Attention</strong> - allows the model to see complex relationships from multiple perspectives</li>
  <li><strong>Positonal Encoding</strong> - adds information about the order of the words in the sentence</li>
  <li><strong>Parallel Processing</strong> - allows faster training as no sequential bottleneck</li>
  <li><strong>Feed-Forward Layers</strong> - gives each token its own small-linear transformation after attention</li>
  <li><strong>Scalability</strong> - powers poweful models across text, images, audio…</li>
</ul>

<h2 id="further-reading">Further Reading:</h2>
<ul>
  <li><a href="https://arxiv.org/pdf/1706.03762">Original paper: <em>Attention Is All You Need</em> (Vaswani et al., 2017)</a></li>
  <li><a href="https://youtu.be/wjZofJX0v4M?feature=shared">3Blue1Brown Video: <em>Transformers the tech behind llms</em> </a></li>
  <li><a href="https://youtu.be/eMlx5fFNoYc?feature=shared">3Blue1Brown 2nd Video: <em>Attention in transformers step-by-step</em> </a></li>
  <li><a href="https://youtu.be/nZrZOI0oRuw?feature=shared">Caleb Writes Code Video: <em>Transformers Explained</em></a></li>
  <li><a href="https://en.wikipedia.org/wiki/Attention_Is_All_You_Need">Wikipedia Article: <em>Attention Is All You Need</em></a></li>
</ul>]]></content><author><name>Thiruwaran Kalvin</name></author><category term="Transformers" /><category term="Paper Summary" /><category term="Research" /><category term="Artificial Intelligence" /><category term="Machine Learning" /><category term="Deep Learning" /><category term="Neural Networks" /><summary type="html"><![CDATA[In 2017, Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uzkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin published the Research Paper “Attention Is All You Need”, which introduced the Transformer model architecture, but is Attention really all you need? In this post, I’ll summarise the key ideas in this Research Paper and share my takeaways of whether or not “Is Attention Really All You Need”?]]></summary></entry><entry><title type="html">My First Neural Network</title><link href="https://t-kalv.github.io/posts/2025/09/2025-09-04-MyFirstNeuralNetwork/" rel="alternate" type="text/html" title="My First Neural Network" /><published>2025-09-04T00:00:00+00:00</published><updated>2025-09-04T00:00:00+00:00</updated><id>https://t-kalv.github.io/posts/2025/09/MyFirstNeuralNetwork</id><content type="html" xml:base="https://t-kalv.github.io/posts/2025/09/2025-09-04-MyFirstNeuralNetwork/"><![CDATA[<p>In this post, I built a <a href="https://github.com/T-Kalv/Simple-Neural-Network/tree/main"><strong>Simple Neural Network for XOR made in Python from Scratch</strong> </a> without any external Machine Learning Libraries/Frameworks such as PyTorch or Tensorflow or JAX.</p>

<h3 id="why-xor">Why XOR?</h3>
<p>XOR (exclusive OR) is a binary logic gate operation that takes two binary inputs (0 or 1) and produces a single output (0 or 1). Here in XOR, the ouput of the operation is equal to 1 if and only if both the inputs are different (not the same inputs). If both inputs are the same, then the ouput is 0.</p>

<p>I chose XOR specifically as it’s the simplest problem to solve for a Neural Network as a single-layer perceptron cannot solve for XOR because the data is not linearly separable. Neural Networks can solve non-linear separable problems by adding hidden layers between the input and output which allows them to learn complex, non-linear decision boundaries such as XOR.</p>

<h3 id="neural-network">Neural Network:</h3>
<p><img width="300" height="261" alt="SimpleNeuralNet" src="https://github.com/user-attachments/assets/12c1908a-7bdf-4368-93bf-fed71f3b583f" /></p>

<p>The Neural network consits of 2 inputs, 3 neurons in the hidden layer which apply the non-linear transformation in this case the sigmoid activation function and in the output layer there is 1 neuron which gives one number between 0 and 1 which represent the predicted probability.</p>

<h3 id="training-neural-network">Training Neural Network:</h3>

<p>The Training process consited of 4*2 matrix of all possible combinations of two binary inputs which is XOR function. These were:</p>
<ul>
  <li>(0,0) -&gt; Expected Output = 0</li>
  <li>(0,1) -&gt; Expected Ouput = 1</li>
  <li>(1,0) -&gt; Expected Output = 1</li>
  <li>(1,1) -&gt; Expected Ouput = 0</li>
</ul>

<p>The goal of the Training the Neural Network was to adjust the weights/biases so that the the output for each of the inputs correspond to the expected output for XOR.</p>

<p>The main steps for Training the Neural Network are as follows:</p>
<ol>
  <li>Forward Propagation - inputs and biases are passed through the Neural Network to generate an output. This invlvec calulating the weighted sums as each of the layers from the input layer, through the hidden layer to the output layer, applying the sigmoid activation function and obtaining the Output Predicition.</li>
  <li>Backpropagation - calulate the error loss between the prediction output and the expected output using the Mean Squared Error Loss (MSE) Function. Then calulate the gradient of the loss with respect to the weights/biases which results in how much each of those weights/biases cotributed to the error. Adjust weights/biases according to error contribtion.</li>
  <li>Sigmoid Activation Function - introduce non-linearity to the Neural Network: 
\(\sigma(x) = \frac{1}{1 + e^{-x}}\)</li>
  <li>MSE (Mean Squared Error) Loss Function - 
\(MSE = \frac{1}{n} \sum_{i=1}^{n} (y_{\text{pred}} - y_{\text{true}})^2\)</li>
</ol>

<h3 id="results">Results:</h3>

<p>After training the Neural Network for <strong>10,000 epochs</strong> with a learning rate of <strong>0.1</strong>, the training process took <strong>0.5556 seconds</strong>. During training, the model adjusted the weights and biases to minimize the loss, and the predictions gradually became more accurate. This resulted in Raw Prections (Before Rounding) and Predicted Classes (After Rounding).</p>

<p><strong>Raw Predictions (Before Rounding):</strong></p>

<table>
  <thead>
    <tr>
      <th>Input (x1, x2)</th>
      <th>Raw Predicted Output</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>(0, 0)</td>
      <td>0.05917951</td>
    </tr>
    <tr>
      <td>(0, 1)</td>
      <td>0.95001299</td>
    </tr>
    <tr>
      <td>(1, 0)</td>
      <td>0.9500065</td>
    </tr>
    <tr>
      <td>(1, 1)</td>
      <td>0.05039647</td>
    </tr>
  </tbody>
</table>

<p><strong>Predicted Classes (After Rounding):</strong></p>

<table>
  <thead>
    <tr>
      <th>Input (x1, x2)</th>
      <th>Predicted Output (After Rounding)</th>
      <th>Expected Output</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>(0, 0)</td>
      <td>0</td>
      <td>0</td>
    </tr>
    <tr>
      <td>(0, 1)</td>
      <td>1</td>
      <td>1</td>
    </tr>
    <tr>
      <td>(1, 0)</td>
      <td>1</td>
      <td>1</td>
    </tr>
    <tr>
      <td>(1, 1)</td>
      <td>0</td>
      <td>0</td>
    </tr>
  </tbody>
</table>

<h3 id="conclusion">Conclusion:</h3>

<p>In conclusion, this <a href="https://github.com/T-Kalv/Simple-Neural-Network/tree/main"><strong>Simple Neural Network for XOR made in Python from Scratch</strong> </a>* successfully learnt the XOR function without any external Machine Learning Libraries/Frameworks such as PyTorch or Tensorflow or JAX, only using basic principles such as Forward Propagation, Backpropagation, Sigmoid Activation Function and MSE (Mean Squared Error Loss) by adjusting the weights/biases through Backpropagation and reducing the loss over time. This resulted in correctly predicing XOR outputs for the given inputs.</p>

<p>The <strong>Simple Neural Network for XOR made in Python from Scratch</strong> source code can be accessed via <a href="https://github.com/T-Kalv/Simple-Neural-Network/tree/main">GitHub</a></p>]]></content><author><name>Thiruwaran Kalvin</name></author><category term="Neural Networks" /><category term="Aritifial Intelligence" /><category term="Machine Learning" /><category term="Deep Learning" /><category term="XOR" /><category term="Python" /><summary type="html"><![CDATA[In this post, I built a Simple Neural Network for XOR made in Python from Scratch without any external Machine Learning Libraries/Frameworks such as PyTorch or Tensorflow or JAX.]]></summary></entry></feed>