<?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 Sergey Arkhangelskiy on Medium]]></title>
        <description><![CDATA[Stories by Sergey Arkhangelskiy on Medium]]></description>
        <link>https://medium.com/@mc.vertix?source=rss-b09558c811bb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*X6XPHzzRoc6LgrRMvsEjeg.jpeg</url>
            <title>Stories by Sergey Arkhangelskiy on Medium</title>
            <link>https://medium.com/@mc.vertix?source=rss-b09558c811bb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 11:45:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mc.vertix/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[Data augmentation on GPU in Tensorflow]]></title>
            <link>https://becominghuman.ai/data-augmentation-on-gpu-in-tensorflow-13d14ecf2b19?source=rss-b09558c811bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/13d14ecf2b19</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-augmentation]]></category>
            <dc:creator><![CDATA[Sergey Arkhangelskiy]]></dc:creator>
            <pubDate>Fri, 24 Nov 2017 12:23:13 GMT</pubDate>
            <atom:updated>2017-11-28T16:34:10.370Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Imagen relacionada" src="https://cdn-images-1.medium.com/proxy/1*FxMUvjm1mlfKJhIC_cOJSw.png" /><figcaption><a href="https://medium.com/@hamedmp/exporting-trained-tensorflow-models-to-c-the-right-way-cf24b609d183">Source</a></figcaption></figure><p>If you solve any real-world problem with images — classification, detection or segmentation, you must be using Convolutional Deep Neural Networks. If you do then I bet you augment your training data or at least you plan to, as data augmentation is a relatively cheap way to improve quality of your model.</p><p>For instance, in image classification case data augmentation relies on the fact that image label doesn’t change under some image transformations. Consider an image of cat – if you flip it horizontally, it’ll be still an image of cat. If you slightly rotate this image, it’s still a cat on it. Depending on your domain, there might be multiple image transformations that keep labels unchanged.</p><p>I use Tensorflow for training neural networks, and there are several libraries for image augmentation available. The most basic is<a href="https://github.com/tensorflow/models/tree/master/research/slim/preprocessing"> </a><a href="https://github.com/tensorflow/models/tree/master/research/slim/preprocessing">preprocessing</a> module from official <a href="https://github.com/tensorflow/models/tree/master/research/slim">Tensorflow classification models zoo</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c03254d542d6c9808666d308dde491c7/href">https://medium.com/media/c03254d542d6c9808666d308dde491c7/href</a></iframe><p>This example makes basic data augmentation (random crops, random left-right flipping, color distortion). In many cases this is good enough 😎.</p><p>If you need something more advanced, there’s <a href="https://github.com/aleju/imgaug">imgaug library</a>. Check out its documentation, it implements really sophisticated augmentation with fine-grained control.</p><p>Despite the simplicity of mentioned libraries they have a major practical drawback — they run their computations on CPU. In many cases this leads to CPU becoming a computation bottleneck.</p><p>In my case I train on Intel Core i7–5820K with 6 cores and 4 GPU (3x1080Ti + Titan X). In this setup training without augmentation easily consumes 1K images per second on relatively complex network architecture. Poor 6 cores doing augmentation are unable to keep pace with GPU, which results in GPU underutilization and increased training times.</p><p>So I had to write my very own augmentation code that runs on GPU. Thanks to awesome tf.contrib.image module I didn’t have to write custom operations and could rely on efficient GPU implementation of <a href="https://www.tensorflow.org/api_docs/python/tf/contrib/image/transform">tf.contrib.image.transform</a> function.</p><p>So far my code supports very basic augmentations — horizontal and vertical flips, rotations, crops and mixup (recent idea suggested in <a href="https://arxiv.org/abs/1710.09412.pdf">https://arxiv.org/abs/1710.09412.pdf</a>). This list can be extended to image shearing and color transformations, so contributions are welcome.</p><p>So here’s my augmentation function and usage example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b4d0ca1dee2ad49a0a99d35609b63c21/href">https://medium.com/media/b4d0ca1dee2ad49a0a99d35609b63c21/href</a></iframe><p>This code lets you run augmentation completely on GPU and leave CPU for reading the data and decoding JPEGs. Note that I convert images to float32 on GPU too, in my practice this helps to squeeze performance a bit.</p><p>Using this approach I managed to fully utilize my first GPU, and for the other 3 utilization stays around 70%. This must be related to gradient averaging and weights transfer between GPUs, but it’s a different story.</p><p>Hope you’ll find this useful and let me know what you think in comments.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F8f5f8b%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2F8f5f8b&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/c43026df6fee7cdb1aab8aaf916125ea/href">https://medium.com/media/c43026df6fee7cdb1aab8aaf916125ea/href</a></iframe><figure><a href="https://becominghuman.ai/artificial-intelligence-communities-c305f28e674c"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*2f7OqE2AJK1KSrhkmD9ZMw.png" /></a></figure><figure><a href="https://upscri.be/8f5f8b"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*v-PpfkSWHbvlWWamSVHHWg.png" /></a></figure><figure><a href="https://becominghuman.ai/write-for-us-48270209de63"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*Wt2auqISiEAOZxJ-I7brDQ.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13d14ecf2b19" width="1" height="1" alt=""><hr><p><a href="https://becominghuman.ai/data-augmentation-on-gpu-in-tensorflow-13d14ecf2b19">Data augmentation on GPU in Tensorflow</a> was originally published in <a href="https://becominghuman.ai/">Becoming Human: Artificial Intelligence Magazine</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>