<?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 Federico Peccia on Medium]]></title>
        <description><![CDATA[Stories by Federico Peccia on Medium]]></description>
        <link>https://medium.com/@pecciaf?source=rss-ce527bed0faf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-66xDbbpkjw0v4gzOnODow.jpeg</url>
            <title>Stories by Federico Peccia on Medium</title>
            <link>https://medium.com/@pecciaf?source=rss-ce527bed0faf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 02:18:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pecciaf/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[Condition-Aware Neural Networks for Image Generation]]></title>
            <link>https://pecciaf.medium.com/condition-aware-neural-networks-for-image-generation-209bfd73c810?source=rss-ce527bed0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/209bfd73c810</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[text-to-image-generation]]></category>
            <dc:creator><![CDATA[Federico Peccia]]></dc:creator>
            <pubDate>Sun, 07 Apr 2024 13:39:45 GMT</pubDate>
            <atom:updated>2024-04-07T13:39:45.285Z</atom:updated>
            <content:encoded><![CDATA[<h3>Condition-Aware Neural Networks for Image Generation: a paper dive</h3><p>Image generation is a fascinating field in Artificial Intelligence used to generate new images from scratch based on text prompts. The main idea is simple: the user inserts a text detailing what he or she wants to generate, and the model outputs an image resembling the provided description. These generated images can be anything, ranging from natural scenes to abstract art or anime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q5HdpEOEYnYKG8GKOkHQ0w.jpeg" /><figcaption>Example of an image generated using Stable Diffusion, a popular text-to-image model. Prompt: “An elephant riding a bike, photorealistic.”.</figcaption></figure><p>This month, a new paper was published about <a href="https://arxiv.org/abs/2404.01143">Condition-Aware Neural Networks (CAN)</a>, a new technique that claims to improve these kind of models. In this article, I will explain the core idea of the paper, and finish with some ethical questions about the use of generative AI (which we <em>cannot</em> and <em>should not</em> ignore). So lets dive into it together, shall we?</p><h4>The premise</h4><p>As you may know, the knowledge of a Neural Network (NN) is encoded inside its parameters. These are huge matrixes whose values are selected during the training of the NN. Once the training finishes, these weights (as they are normally called) are fixed and do not change. They are tailored for the trained tasks.</p><p>The core idea of the paper is to introduce the Condition-Aware Neural Network (CAN) as a novel method for enhancing control in generative models. They asked themselves: can we modify on-the-fly the weights of a NN based on what the user wants to generate, and does this improve the generative process?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wXZgjL_O9dXno5xO8QKRFg.png" /><figcaption>Left: a schematic of the usual image generation model. Right: the new approach including the on-the-fly generation of new weights. Image from original paper.</figcaption></figure><h4>How to select to which layers the condition should be applied?</h4><p>The selection of layers to which this conditional weight generation is applied is a crucial design decision. It is not practical to make all NN layers condition-aware, as this would add a significant overhead to the training of the network.</p><p>In order to find the layers to apply this technique to, they performed ablation studies and performance analysis on the output metrics of the model to try to identify the combination of condition-aware layers that result in the most significant performance boost while maintaining computational efficiency.</p><p>They found that making a layer condition-aware does not directly mean that the performance will be improved. They found that making depthwise convolutions, patch embedding and output projection layers condition-aware provides a significant boost to the performance.</p><h4>Results</h4><p>They demonstrated that remarkable improvements can be achieved by the CAN approach compared to existing state-of-the-art methods. Compared to previous works, their models achieve better metrics on common datasets like COCO and ImageNet. The interesting part is that this technique can be integrated with existing transformers models for image generation like <a href="https://arxiv.org/abs/2212.09748">DiT</a> and <a href="https://arxiv.org/abs/2209.12152">UViT</a>, leading to substantial performance boosts while incurring minimal computational cost increases.</p><h4>Conclusion and final thoughts</h4><p>CAN’s adaptability and flexibility have the potential to revolutionize applications in art, design, entertainment, and other fields requiring customized image synthesis. In a broader context, CAN’s ability to tailor image generation to specific conditions opens up new possibilities for personalized content creation, automated design processes, and innovative visual storytelling.</p><p>Of course, although the technique is interesting, we cannot ignore the ethical problems that arise from using generative AI models. How do we still protect intellectual property rights and copyright? How do we avoid the use of this models for the creation of deep-fake content? How do generative models impact cultural and artistic integrity? How can we avoid the perpetuation of stereotypes or biases while using these kind of models?</p><p>Feel free to follow me on <a href="https://www.linkedin.com/in/fpecc/">LinkedIn</a> and let me know what you think of this article, or <a href="https://www.buymeacoffee.com/pecciaf">buy me a coffee</a> if you really liked it!</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=209bfd73c810" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Insights from a Computer Science conference: DATE 2024]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://pub.towardsai.net/insights-from-a-computer-science-conference-date-2024-f01b0671d219?source=rss-ce527bed0faf------2"><img src="https://cdn-images-1.medium.com/max/2600/1*mjNrcarqAIMbd5VALP3UfA.jpeg" width="3024"></a></p><p class="medium-feed-link"><a href="https://pub.towardsai.net/insights-from-a-computer-science-conference-date-2024-f01b0671d219?source=rss-ce527bed0faf------2">Continue reading on Towards AI »</a></p></div>]]></description>
            <link>https://pub.towardsai.net/insights-from-a-computer-science-conference-date-2024-f01b0671d219?source=rss-ce527bed0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/f01b0671d219</guid>
            <category><![CDATA[conference]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[embedded-systems]]></category>
            <dc:creator><![CDATA[Federico Peccia]]></dc:creator>
            <pubDate>Fri, 29 Mar 2024 16:02:27 GMT</pubDate>
            <atom:updated>2024-03-29T16:02:27.998Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Auto-tuning for Deep Neural Network deployment]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/data-science/auto-tuning-for-deep-neural-network-deployment-ff2324cb41d?source=rss-ce527bed0faf------2"><img src="https://cdn-images-1.medium.com/max/2600/0*Db8CzI75x1OVJzmp" width="6000"></a></p><p class="medium-feed-snippet">What, why and most importantly&#x2026; how?</p><p class="medium-feed-link"><a href="https://medium.com/data-science/auto-tuning-for-deep-neural-network-deployment-ff2324cb41d?source=rss-ce527bed0faf------2">Continue reading on TDS Archive »</a></p></div>]]></description>
            <link>https://medium.com/data-science/auto-tuning-for-deep-neural-network-deployment-ff2324cb41d?source=rss-ce527bed0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff2324cb41d</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[tips-and-tricks]]></category>
            <category><![CDATA[edge-computing]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[Federico Peccia]]></dc:creator>
            <pubDate>Fri, 01 Sep 2023 17:28:29 GMT</pubDate>
            <atom:updated>2023-09-01T17:28:29.749Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Green AI: methods and solutions to improve AI sustainability]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/data-science/green-ai-methods-and-solutions-to-improve-ai-sustainability-861d69dec658?source=rss-ce527bed0faf------2"><img src="https://cdn-images-1.medium.com/max/2600/0*TZ_fELp4T4UsSo7r" width="4858"></a></p><p class="medium-feed-snippet">A technical look at a long overdue topic</p><p class="medium-feed-link"><a href="https://medium.com/data-science/green-ai-methods-and-solutions-to-improve-ai-sustainability-861d69dec658?source=rss-ce527bed0faf------2">Continue reading on TDS Archive »</a></p></div>]]></description>
            <link>https://medium.com/data-science/green-ai-methods-and-solutions-to-improve-ai-sustainability-861d69dec658?source=rss-ce527bed0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/861d69dec658</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[green-ai]]></category>
            <category><![CDATA[data-for-change]]></category>
            <category><![CDATA[sustainability]]></category>
            <category><![CDATA[energy-efficiency]]></category>
            <dc:creator><![CDATA[Federico Peccia]]></dc:creator>
            <pubDate>Mon, 26 Jun 2023 20:46:39 GMT</pubDate>
            <atom:updated>2023-06-26T20:46:39.602Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Galactica: how to (responsibly) use the language model everyone is talking about]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://pub.towardsai.net/galactica-how-to-responsibly-use-the-language-model-everyone-is-talking-about-31882a7c7339?source=rss-ce527bed0faf------2"><img src="https://cdn-images-1.medium.com/max/2600/0*y2LF9lSWr-1UiBiW" width="7952"></a></p><p class="medium-feed-snippet">&#x2026; and the controversy around it</p><p class="medium-feed-link"><a href="https://pub.towardsai.net/galactica-how-to-responsibly-use-the-language-model-everyone-is-talking-about-31882a7c7339?source=rss-ce527bed0faf------2">Continue reading on Towards AI »</a></p></div>]]></description>
            <link>https://pub.towardsai.net/galactica-how-to-responsibly-use-the-language-model-everyone-is-talking-about-31882a7c7339?source=rss-ce527bed0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/31882a7c7339</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[large-language-models]]></category>
            <dc:creator><![CDATA[Federico Peccia]]></dc:creator>
            <pubDate>Sat, 10 Dec 2022 12:02:03 GMT</pubDate>
            <atom:updated>2022-12-10T12:02:03.683Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How DeepMind discovered new ways of multiplying matrices using AI…]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/data-science/how-deepmind-discovered-new-ways-of-multiplying-matrices-using-ai-a04557e9f861?source=rss-ce527bed0faf------2"><img src="https://cdn-images-1.medium.com/max/2600/0*FSeEOyJ_s5dny0Wq" width="4000"></a></p><p class="medium-feed-snippet">&#x2026;and why its such a big deal</p><p class="medium-feed-link"><a href="https://medium.com/data-science/how-deepmind-discovered-new-ways-of-multiplying-matrices-using-ai-a04557e9f861?source=rss-ce527bed0faf------2">Continue reading on TDS Archive »</a></p></div>]]></description>
            <link>https://medium.com/data-science/how-deepmind-discovered-new-ways-of-multiplying-matrices-using-ai-a04557e9f861?source=rss-ce527bed0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/a04557e9f861</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[energy-efficiency]]></category>
            <dc:creator><![CDATA[Federico Peccia]]></dc:creator>
            <pubDate>Tue, 01 Nov 2022 13:36:48 GMT</pubDate>
            <atom:updated>2022-11-01T13:36:48.183Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Accelerating neural networks on hardware]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/data-science/accelerating-neural-networks-on-hardware-baa3c14cd5ba?source=rss-ce527bed0faf------2"><img src="https://cdn-images-1.medium.com/max/960/1*ZoZEazVnhM9UzrkgLuTMxg.png" width="960"></a></p><p class="medium-feed-snippet">How Systolic Arrays work</p><p class="medium-feed-link"><a href="https://medium.com/data-science/accelerating-neural-networks-on-hardware-baa3c14cd5ba?source=rss-ce527bed0faf------2">Continue reading on TDS Archive »</a></p></div>]]></description>
            <link>https://medium.com/data-science/accelerating-neural-networks-on-hardware-baa3c14cd5ba?source=rss-ce527bed0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/baa3c14cd5ba</guid>
            <category><![CDATA[digital-circuit-design]]></category>
            <category><![CDATA[edge-computing]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[hardware-accelerator]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[Federico Peccia]]></dc:creator>
            <pubDate>Thu, 06 Oct 2022 15:27:38 GMT</pubDate>
            <atom:updated>2022-10-06T15:27:38.801Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Batch normalization: theory and how to use it with Tensorflow]]></title>
            <link>https://medium.com/data-science/batch-normalization-theory-and-how-to-use-it-with-tensorflow-1892ca0173ad?source=rss-ce527bed0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/1892ca0173ad</guid>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[batch-normalization]]></category>
            <dc:creator><![CDATA[Federico Peccia]]></dc:creator>
            <pubDate>Sun, 16 Sep 2018 00:52:45 GMT</pubDate>
            <atom:updated>2019-01-09T20:06:00.542Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8mSbe4y1nczVWR64" /><figcaption>“time-lapse photography of highway road” by <a href="https://unsplash.com/@cmreflections?utm_source=medium&amp;utm_medium=referral">Clément M.</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Not so long ago, deep neural networks were really difficult to train, and making complex models converge in a reasonable amount of time would have been impossible. Nowadays, we have a lot of tricks to help them converge, to achieve faster training and to solve any kind of trouble that arise when we want to train a Deep Learning model. This article is going to explore one of those tricks: <strong>batch normalization.</strong></p><h4>Why you should use it</h4><p>In order to understand what batch normalization is, first we need to address which problem it is trying to solve.</p><p>Usually, in order to train a neural network, we do some preprocessing to the input data. For example, we could normalize all data so that it resembles a normal distribution (that means, zero mean and a unitary variance). Why do we do this preprocessing? Well, there are many reasons for that, some of them being: preventing the early saturation of non-linear activation functions like the sigmoid function, assuring that all input data is in the same range of values, etc.</p><p>But the problem appears in the intermediate layers because the distribution of the activations is constantly changing during training. This slows down the training process because each layer must learn to adapt themselves to a new distribution in every training step. This problem is known as <strong>internal covariate shift</strong>.</p><p>So… what happens if we <em>force </em>the input of every layer to have approximately the same distribution in every training step?</p><h4>What it is</h4><p>Batch normalization is a method we can use to normalize the inputs of each layer, in order to fight the internal covariate shift problem.</p><p>During training time, a batch normalization layer does the following:</p><ol><li>Calculate the mean and variance of the layers input.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*_6xWFQC0jb9_T1yz9iqOWA.png" /><figcaption>Batch statistics for step 1</figcaption></figure><p>2. Normalize the layer inputs using the previously calculated batch statistics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*I7YluVpp6-mfMoj4AZZI5g.png" /><figcaption>Normalization of the layers input in step 2</figcaption></figure><p>3. Scale and shift in order to obtain the output of the layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*G8-bO54pVT5eJCJ7MBabdA.png" /><figcaption>Scaling and shifting the normalized input for step 3</figcaption></figure><p>Notice that <em>γ</em> and <em>β</em> are <strong>learned during training</strong> along with the original parameters of the network.</p><p>So, if each batch had <em>m </em>samples and there where <em>j</em> batches:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*j9KW8tVE8XTEu6lcP1dFoQ.png" /><figcaption>Inference formulas</figcaption></figure><p><strong>Edit:</strong> During test (or inference) time, the mean and the variance are fixed. They are estimated using the previously calculated means and variances of each training batch.</p><h4>How do we use it in Tensorflow</h4><p>Luckily for us, the Tensorflow API already has all this math implemented in the <a href="https://www.tensorflow.org/api_docs/python/tf/layers/batch_normalization">tf.layers.batch_normalization</a> layer.</p><p>In order to add a batch normalization layer in your model, all you have to do is use the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd42ec411c9c9cf239f8ae1d7301a6ef/href">https://medium.com/media/bd42ec411c9c9cf239f8ae1d7301a6ef/href</a></iframe><p>It is really important to get the update ops as stated in the Tensorflow documentation because in training time the moving variance and the moving mean of the layer have to be updated. If you don’t do this, batch normalization <strong>will not work</strong> and the network <strong>will not train</strong> as expected.</p><p>It is also useful to declare a placeholder to tell the network if it is in training time or inference time (we already discussed which are the differences for train and test time).</p><p>Notice that this layer has <strong>a lot</strong> <strong>more </strong>parameters (you can check them in the documentation), but these is the basic working code that you should use.</p><h4>References</h4><p>If you feel curious about batch normalization, I encourage you to take a look at this papers and videos:</p><ul><li><a href="https://arxiv.org/pdf/1502.03167.pdf">Sergey Ioffe, Christian Szegedy, Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift, 2015</a></li><li><a href="https://arxiv.org/abs/1603.09025">Tim Cooijmans, Nicolas Ballas, César Laurent, Çaglar Gülçehre, Aaron Courville, Recurrent Batch Normalization, 2016</a></li><li><a href="https://arxiv.org/abs/1806.02892">Mahdi M. Kalayeh, Mubarak Shah, Training Faster by Separating Modes of Variation in Batch-normalized Models, 2018</a></li><li><a href="https://www.youtube.com/watch?v=wEoyxE0GP2M&amp;index=6&amp;list=PLC1qU-LWwrF64f4QKQT-Vg5Wr4qEE1Zxk">Stanford University School of Engineering CS231n Lecture 6 | Training Neural Networks I, 2017</a></li><li><a href="https://arxiv.org/abs/1807.01702">Daejin Jung, Wonkyung Jung, and Byeongho Kim, Sunjung Lee, Wonjong Rhee, Jung Ho Ahn, Restructuring Batch Normalization to Accelerate CNN Training, 2018</a></li></ul><p>Feel free to follow me on <a href="https://twitter.com/PecciaF">Twitter</a> or <a href="https://www.linkedin.com/in/fpecc/">LinkedIn</a> and let me know what you think of this post. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1892ca0173ad" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/batch-normalization-theory-and-how-to-use-it-with-tensorflow-1892ca0173ad">Batch normalization: theory and how to use it with Tensorflow</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>