<?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 Andrew Charneski on Medium]]></title>
        <description><![CDATA[Stories by Andrew Charneski on Medium]]></description>
        <link>https://medium.com/@acharneski?source=rss-b5d0d73f6aa4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Nsn9giqZGHsjb5vV49zTpQ.jpeg</url>
            <title>Stories by Andrew Charneski on Medium</title>
            <link>https://medium.com/@acharneski?source=rss-b5d0d73f6aa4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 03:37:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@acharneski/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[Geometric Symmetry in Deep Texture Generation]]></title>
            <link>https://medium.com/swlh/geometric-symmetry-in-deep-texture-generation-be674ecb7190?source=rss-b5d0d73f6aa4------2</link>
            <guid isPermaLink="false">https://medium.com/p/be674ecb7190</guid>
            <category><![CDATA[geometric-deep-learning]]></category>
            <category><![CDATA[symmetry]]></category>
            <category><![CDATA[ai-art]]></category>
            <category><![CDATA[style-transfer]]></category>
            <category><![CDATA[mc-escher]]></category>
            <dc:creator><![CDATA[Andrew Charneski]]></dc:creator>
            <pubDate>Sun, 31 Jan 2021 00:00:00 GMT</pubDate>
            <atom:updated>2021-02-04T16:52:39.342Z</atom:updated>
            <content:encoded><![CDATA[<p>Recent work in neural style transfer has been successful in producing stunning images with a very similar look to real paintings, while resembling photographs in content. However, these images tend to lack certain qualities that you find in some pieces, such as the geometric symmetry found in much of MC Escher’s work.</p><p>Existing techniques are too freeform to replicate the geometric perfection that is the aesthetic quality of this art style. In this paper, we explore a new technique to generate textures with symmetry. This is not a technical paper, although the concepts can become technical for the reader who researches them; key technical terms and brief descriptions are provided where appropriate.</p><p>By modifying the technique and adding some additional layers which enforce strict symmetry and configurable views, we can introduce hard symmetry and open up a whole host of techniques to play with. The concept is simple, and would be familiar to anybody who has ever taken a close look at a kaleidoscope or has ever made snowflakes and grade school by folding and cutting paper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9GmXf8Pu6E9maBNS.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mVeDyyvunUOcVK1G.png" /></figure><p>All of the AI generated art that you see here was made by my software, MindsEye, which is fully open source and can be run on your own machine (if you have the required hardware) or on AWS. Details are given near the end of the paper.</p><p>Many of these designs may look vaguely familiar. In particular MC Escher, one of my favorite artists of all time, explored this area so well that for many of the examples I’ve generated below, I can also cite some very similar (but much better!) prior art from his work. Truly this paper would not exist without the inspiration of his work.</p><h3>Rendering Process</h3><p>You have no doubt heard about the impressive imagery that modern day AI can create. I don’t want to get lost in the details of this fascinating topic, but I do want to briefly introduce two important AI based image generation techniques. The first is Deep Dream, published by Google to enhance images in a way that seems eerily familiar to anybody who’s taken hallucinogenic drugs. Another is deep style transfer, which shows an impressive ability to mimic an artist’s style while rendering nearly any given input photograph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*YzSk6VF21GciuWsK.jpg" /></figure><p>Original Deep Dream demonstration image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TOEyCSxC2TnwTNy7.png" /></figure><p>The exhibit photo for A Neural Algorithm of Artistic Style</p><p>Both of these use a technique called “Transfer Learning”, where they piggyback off of existing image processing neural networks. They almost literally do neurosurgery, cutting off the first N layers of the network in order to yield an image processing device. This is then spliced with other components which seek to maximize or match a signal. Because neural networks are designed to be optimized we can “learn” whatever image causes a given neuron to activate the most, for example. If you identify the “cat” neuron, you can cause your image to contain many cats by optimizing its activation.</p><p>These networks are pre-trained for other purposes, and the learning process is also a given, so we can pretty much treat the technical details of those components as a black box. The important thing is what we’re adding around the black box and why. We really don’t need to worry about the details of these neural networks any more than a painter needs to understand neurobiology.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/0*ED5BJDSyy0GJW5DJ.png" /></figure><p>A good analogy to understand this is to think about a human artist. That artist uses their vision system in everyday life, but today they are using it to make a painting. Whatever they have currently painted on the canvas goes through their eyes, is processed by the vision system, and then is interpreted by the brain. The artist asks “is this what I want?’’ and it then sends instructions through the spinal cord to add new brush strokes to the painting (or throw it into a fire). Where the physical act of painting is handled by the hand (via the spinal cord), the changing of an objective image is handled by the optimization algorithms of the neural network platform. Where the human artist’s existing vision system is used to interpret the painting in progress, an AI artist uses a preexisting vision network to interpret the working canvas. In both deep dream and deep style transfer, the objective is key in determining the image; similarly, the human artist’s output is determined by the conscious ideas in their own head. The Deep Dream objective attempts to maximize the outputs of certain neurons, for example the “cat” neuron to focus on cats. The Style Transfer objective attempts to match the pattern of activations, on average, to a style image.</p><p>My experimentation has used basically the same process but adds an additional “opticals” in front, before the neural vision layers. This is very much like the human artist viewing their painting through a kaleidoscope and designing the painting to look appropriate in that context. This article is more about the construction of that “Kaleidoscope” than it is about any of these other components.</p><p>Another important detail is pre-processing and post-processing. We may want to pre-process any style images we intend on using by correcting the color, sharpening, or other effects that make the desired texture most prominent. The better the texture, the better the output. Once the output is ready, it is often post-processed to enhance the final color and contrast.</p><h3>Geometric Symmetry</h3><h3>Flat Space</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JzdbviYOorSsAinm.png" /></figure><p>This project started when I was playing with AI texture generation and trying to develop textures that are capable of tiling. I wanted images suitable for a desktop or web background. The solution was to not only optimize a view of the normal tile but to optimize it pre-tiled as a 2x2 square. This caused the network to not only produce a texture, but to seek one which avoided any unsightly discrepancy despite the periodic nature. This works well, and we can use any aspect ratio (for square, wide, or thin tiles) but we always see the same rectangular repetition which is noticeable and not very aesthetically pleasing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*CwPaQSXhuibIAy0I.png" /></figure><p>My next experiment was with symmetric effects, by enforcing the canvas to be “degenerate”, meaning it can only take on certain values. This is performed by having an objective image which is then transformed and superimposed upon itself in such a way that the “kaleidoscope” output has the resulting symmetry. In this example, if you rotate the painting 180 degrees, it looks the same. Once the painting is complete, we record what the source painting looks like via our “kaleidoscope” transformation, then discard the original source painting.</p><p>Another interesting effect is found by requiring a color change in addition, as in “if you rotate the painting by 120 degrees, it will look the same if you also change blue to green, green to red, and red to blue.” A multi-colored symmetry is produced. One could also say “Flip White and Black” or “Invert the Red channel”. All of these are known as what is called a signed permutation group, and can be written as something like (2,3,1) or (g,b,r) to state what the tuples (1,2,3) or (r,g,b) look like after a single permutation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*O9PVk0ae4YguOLzU.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*vymjv7MBzXX51rUT.jpg" /></figure><p>This could be attempted with any parameters, however I found that many of the sets of parameters simply didn’t work. The training failed. It turns out that only some combinations of requirements are achievable. For example, if you have a 2-way rotational symmetry, you need to use a color permutation that, if you apply it 2 times, will result in the original color scheme. There is no way to make a painting look like you swap (r,g,b)-&gt;(g,b,r) when you rotate by 180 degrees, because another flip of 180 degrees must look like the original, but permuting the colors twice give you (r,g,b)-&gt;(g,b,r)-&gt;(b,r,g). The only way for this to work is if r=b=g, and the image is monochromatic, but in practice this simply does not converge. With that permutation,only after a third transformation do we get the original (r,g,b). In mathematics, this is known as a “ring” of size 3.</p><p>Additionally, it clearly mattered what aspect ratio I was using for the tile. Most rotational symmetries worked fine at 1:1, but at other aspect ratios, convergence simply failed. It turns out there are only two aspect ratios that work: 1:1 (a square) and sqrt(3):2 (a hexagon). Some other values converge for most of the painting, but leave some regions “fuzzy”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*am6nQTuDw209u3cs.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*-nUrngETIG9D-iNx.png" /></figure><p>To explain this, it turns out to relate to how there are only a few very specific ways that you can achieve a regular polygonal tiling on an infinite plane. All of these regular tilings are embeddable within a rectangular unit tile with a particular aspect ratio. Each corresponds to a valid configuration of symmetries that may converge. If that aspect ratio permits a particular tiling, and the rotational symmetry encourages the appropriate polygonal pattern, a natural tiling pattern emerges. Interestingly, rotationally symmetric focal points then emerge corresponding to the neighbor polygons in that unit tile. A good survey of the regular tilings of a torus (i.e. infinite plane), with illustrations of the unit tile defining the periodicity, is given at <a href="http://www.weddslist.com/groups/genus/1/top.php">http://www.weddslist.com/groups/genus/1/top.php</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QbRKsNkmV3WsvKPE.png" /></figure><p>Some aspect ratio choices do mostly converge, and end up creating more complex tiling patterns such as below. Although an interesting result, notice the fuzziness in the diagonal areas, and odd patten reuse between the horizontal and vertical joining areas.</p><h4>Partial Degeneracy</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/0*OnQUNx19C6KaY1pr.png" /></figure><p>If you have 6 fold symmetry that you are prescribing, you have to “fold” the canvas six times. For rotational symmetry, one way to do this is to take 6 copies of the source image, rotate each to an increment of 60°, then average each of the superimposed images. An interesting thing happens if you use the same angle, but you only use one or two superpositions instead of the full six. Mathematically, you are introducing less degeneracy, or you are removing less information from the potential solutions. In practice, this produces a pattern which is “almost” rotationally symmetric. If you rotate the painting by 60° now, the painting changes a little bit (and only a little bit!)</p><p>This effect of limited degeneracy can also be used via translations (as opposed to rotations.) By “folding only once”, a mostly-periodic pattern is produced wherein spatial changes should be linear across any 3 cells. That is, we can produce a tile where the pattern tends to repeat itself with a specific periodicity independent of the tile width. This effect, enforced both horizontally and vertically, does an interesting job of mimicking images of writing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H6KFFTWhxvMVadzv.png" /></figure><p>On the right, only the first of 5 folds are used, producing limited degeneracy and a self-similarity at short distances. On the left, the 2nd of 5 folds was used, producing the same amount of degeneracy but with a more distributed self-similar behavior.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*xRqPqaD-IB3w5dRs.png" /></figure><p>The ability of a regular tiling to morph from one pattern into another was also explored by Escher, notably in his “Metamorphosis” series.</p><h3>The Sphere</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/0*lCYxgqqb4Tdc_jiQ.gif" /></figure><p>Of course, flat images produce fairly poor texture maps for 3D objects. This is why you can’t make a paper map covering a globe without a lot of distortion somewhere. Having a covering of an infinite plane is actually equivalent to having covered a torus, topologically speaking, and spheres are simply different animals!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*rnterf0IXQWv9ovO.gif" /></figure><p>If you want to use AI to produce a texture map of a sphere, you need a view layer that can project your texture map onto the sphere before the AI vision system perceives it. Also, since it is impossible to see the entire surface of a sphere from one viewpoint, we need to simultaneously optimize many different viewpoints to produce a balanced result. An experiment notebook has been prepared which does exactly this, and produces interesting textures on a sphere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*vJHoqFQSsmMR2UlO.gif" /></figure><p>Now that we can paint a sphere, can we do something like the Kaleidoscope effect, but rotating in three dimensions? It turns out we can! For a reason similar to the regular tiling of the infinite plane problem discussed above, it turns out that only some setups of this symmetry work out. These setups are known as rotational groups in mathematics. Skipping the mathematics, I have prepared 3 setups using rotational groups. These are structurally equivalent to the tetrahedron, octahedron, and icosahedron. An interesting side effect of producing a texture with rotational symmetry is that less views are needed, and we may be able to see the entire tile in a single view. Thus, the generation process can be much faster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/0*tU2k8rEvSAk_VbGE.png" /></figure><p>Due to its relevance to objects in the physical world, this type of texture generation seems to have the most practical purpose. Two things I’ve started to look at are texture generation for general 3d models, and using these textured spheres to produce 3d printed sphere sculptures similar to the “Escher Orbs”, like this reproduction being sold on Amazon.</p><h3>Hyperbolic Space</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*V6mniL-feBLI80E4.jpg" /></figure><p>In geometry, spherical space is known as “curved” and paper-like surfaces are known as “flat”. Specifically, the sphere’s curvature is “positive”. This is because the surface curves in the same direction on both axes. Imagine you are standing on a giant surface. If the surface curves down in all directions, you are standing on top of a ball with positive curvature. With paper, you can only curve it in one direction; this curvature prevents any curvature in the opposite direction. This property is why we can make paper fold so neatly. Paper has “zero curvature”. You can also have “negative curvature” by having the surface curve in different directions. If you were standing on a surface, it might curve uphill in front and behind you but downhill on the left or right. This sort of curvature is called a “saddle” or “hyperbolic”.</p><p>Hyperbolic space is really weird, and I do not intend to dive into the mathematics of it nor do I pretend I can explain it simply. So I’ll just call it “magic” and point out a few cool things about it. First, the main reason we care about hyperbolic space here is that it permits some very unique tiling behaviours that compliment the ones we’ve already explored. Symmetric tiling is what causes the interesting geometric properties of hyperbolic space to become visible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*p2t2Ctu0ib_qiJ09.jpg" /></figure><p>You may remember from math class that it is the angles within a polygon that determine if it can tile or not. The angle of a triangle, 60°, can be multiplied by 6 to form a full circle of 360 degrees. A square produces 360° by using four of its 90° vertices. Three hexagons work, but pentagon’s don’t. Nothing above hexagons work in flat space. This is all because there are 360 degrees in a circle in flat space. If curve space, however, the number of degrees contained within a circle depends on its size! If we were driving on a giant race track in hyperbolic space, each lap would involve turning much more than 360 degrees. (Homework: Build a racing game where the track is laid out in curved space.) That means we are less constrained, and there are many more workable arrangements for tiling. Now we can tile using pentagons!</p><p>I’d like to point out some features of the way we are packing all of this into a circle. This is known as a Poincare disk, and it is a well-studied mathematical representation of hyperbolic space. I don’t want to get into the details of projective geometry, but suffice it to say that this representation preserves angles but distorts distances and areas. Therefore, the repeating vertices in the image I’ll have the same angular symmetry, although they are smaller and more compact near the edge. This gives the representation a sort of global consistency and aesthetic. Another property of this representation that adds to the aesthetic appeal is that all straight lines form circles which intersect the boundary circle perpendicularly. Since a lot of tiling patterns produce infinite straight lines, the Poincare disk representation shows these lines as neatly arranged circles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*ctypVaI3Hvwk4biH.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YJzeSc-TOh6IXTsL.jpg" /></figure><p>The above left image is made of squares, six of which meets at every vertex. This is obviously something you can’t do in normal space. We would call this tiling 4–6, because it is a four-sided polygon, with six of them meeting at each vertex. You could also have 3–20, for example, where 20 triangles meet at each of the three points of each tile, as the above right shows.</p><p>The Poincare disk is of course not the only way to represent hyperbolic space. I’ve experimented with a number of different options, and the best-looking variant in my opinion is to simply stretch the circle into a square. Note that applying this distortion during painting is critical; although a circular result could be distorted into a square afterwards, it would appear distorted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*clqDUvRxyIRnIs5y.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*_YgRuzuZcvsCSwlh.png" /></figure><h3>Other Setups</h3><p>These three types of geometry above form an elegant set with plenty of room to experiment, but as you can imagine there is a lot of room left to explore. Nearly any tiling arrangement or image distortion and replication effect could be used. For example, here is a zooming-repetition effect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*qwfadCyW-ZQvVVSK.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/0*L_rRSVQcBQccdmXe.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*PtJsIy8E5wMBwUjM.gif" /></figure><p>Instead of enforcing rotational symmetry, here we rotate with each stage of magnification.</p><h3>Emergent Symbols</h3><p>This process, by design, generates random patterns that are interesting to a human eye. It does this out of a blind desire to make certain neurons “fire,” but the brain involved isn’t even close to complex enough to understand symbol meanings. You can encourage certain patterns to appear, such as buildings, but the best results in doing this generally need to use a network trained to recognize and classify buildings, not just distinguish buildings from cats.</p><p>However, if you generate enough random patterns and look deeply at them, similar to looking at a cloudy sky on a lazy day, you will see some interesting things. A couple of my favorites are given here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/0*b3kk3_95xzZ3v3LF.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*59bi4q6kN1zKaZZe.png" /></figure><p>Some other symbols emerge recurrently, though. Some are indicative of the texture being used, and others can be encouraged by symmetry constraints. In particular, when 4-, 5-, or 6-fold rotational symmetry is used without color permutations, emergent symbols include swastikas, pentagrams, and stars of david, respectively. A good way to prevent this is to introduce a color permutation. A note of cultural sensitivity: The swastika, which is used by many cultures but is marred by the events surrounding WWII, should always be displayed such that the counterclockwise pointedness is dominant (卍). This is actually a sauwastika, not a swastika. Even still, display sparingly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*ZMzcUqQySPt9brKv.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*hOo_E85H7SeFacXd.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*wcXthXjOiTJKY60B.png" /></figure><h3>How to make your own</h3><p>Around 2015 when style transfer and deep dream were published, I became very interested in this technology and wanted to build my own experiments. The project took on a life of its own, and over the next five years I built in my spare time a complete artificial intelligence platform in Java. Throughout this project I’ve explored and written about a number of different research concepts I have explored, but this is by far the most interesting from a visual perspective.</p><p>The easiest way to run this yourself is to use AWS; All of the “recipies” shown at <a href="http://symmetry.deepartist.org/">http://symmetry.deepartist.org/</a> contain a link at the top “To Run Again On EC2” which contains the needed information to start a cloud-based AI rendering. There are an infinite spectrum of creations possible using this software, and if anybody does make anything interesting I would love to hear about it!</p><h3>Recipe Catalog</h3><p>One problem with modern AI is that it requires specialized and expensive hardware. By running on the cloud, you can pay for the hardware by the hour and also skip a lot of the system setup. All of the experiments I run are automatically published to sites as notebooks where the instructions for re-running a given them are also given.</p><p>For recipes related to the work in this paper, look at <a href="http://symmetry.deepartist.org/">http://symmetry.deepartist.org/</a> to view the gallery. Each recipe type is listed separately, and the most recent example of that recipe is displayed. By following the recipe name link, you can view all previous runs of that recipe type. Following the link on any of the images takes you to the full report of that single run.</p><p>When looking through a report, the first thing you may notice is the text area with json. This specifies the run parameters that were used, and at runtime this was editable. There are also a couple of links near the top. The first, entitled “to run this again on ec2”, provides instructions with the needed command to start an ec2 instance with that recipe running. (Please note that some of these recipes will not work, since they were executed on my local machine. For ease of use, I’ve included a few recipes below which I’ve tested.) The second link is debugging information about the system, and is not discussed here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/64/0*OKxtjhpafpuWd6lb.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/128/0*fFi7-im0pPgmTIsR.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/0*EMlX_hhSVCFr942R.jpg" /></figure><p>The report then continues, containing rendered images and links into sub-reports describing the process used to create them. The reader will see that this is a multiresolution process. In the first phase the painting is rendered with a small resolution. Once the small painting is finished, the canvas is enlarged and the rendering process is restarted. By performing the rendering process repeatedly over multiple scales, we allow the neural network to construct image features both large and small.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/64/0*plZV5VuFR1Y_O6l8.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/128/0*eEbowwcgV_8Sfwcw.gif" /></figure><p>By following links deeper into the subreports, the reader can even view details of the optimization process itself, revealing how the image converges over time. Here we can see the first, lowest resolution phase where the initial image emerges from random noise. We then scale the image up and repeat the process, refining finer details.</p><h3>Running a Recipe on AWS</h3><p>This does however require an AWS account with some initialization. AWS accounts are free in that there is no subscription fee, and that you simply pay for what you use. However, it is fairly easy to spend a lot of money in machine time, so be careful! I typically for this project I pay about $5 a month, but my bill was once over $1,000!</p><p>AWS accounts are not required to run this project. If you have the appropriate hardware, specifically a high end Nvidia graphics card with plenty of RAM for both your CPU and GPU, you can get this to work locally with some system setup.</p><p>Assuming you’re completely new to AWS, but willing to make an account today, there are some things you need to do before you get to play!</p><ul><li>First, you will need to configure yourself as an admin user and set up your environment so that you can use the AWS command line tools with your account.</li><li>Configure a security group and open port 1080 is open to the public</li><li>Configure an IAM profile for the EC2 instance with access to any S3 buckets that you want to publish to and the VerifyEmailIdentity permission.</li><li>Set up an SSH key for your instance, this will be needed to SSH into it, but also to create it at all.</li></ul><p>Once these entities are set up and you have the name values for them, you can use the script given in a recipe. This is a bash script, but bash can easily be set up in any modern operating system.</p><p>Create a new .sh file, and insert the script. Next we edit it to configure the Security Group, IAM instance profile, ssh key name, and email address. Then, simply run the script and wait a few minutes for the instance to start. Find out the IP address from the AWS Management console, and visit that host at port 1080 after a few minutes.</p><p>The first step in the application once it is running is to confirm or edit the starting parameters. These are displayed as a text box in Json format. If you want to save your work, you will want to edit the S3 bucket property to be a bucket that you have access to. If this S3 bucket is set up to host a static website, you will get a website in the same format as the recipe gallery. Each recipe can contain a number of additional parameters. Make any desired edits, and click the submit button.</p><p>This will start the application, and after some initialization it will open one or more subreports. Follow the link into the subreports, and you will see a prompt where the application asks you to upload a style image. Choose a style image, upload it, and then refresh the page. It will then ask for another image. If you want to specify multiple images, upload them sequentially. When you are done, press cancel. Then go back to the main page and refresh. Processing will have begun and this page will display its progress whenever refreshed.</p><p>The application logic is generally very good about shutting the instance down when it is done, but since you are paying for it, you should always double-check. Because the instance shuts down at the end automatically, it is highly recommended that you set up publishing to S3.</p><h3>Tested Recipes</h3><p>Just replace ***SECURITY GROUP***, ***IAM PROFILE***, ***SSHKEY***, and ***EMAIL***</p><h4>Whirlpool</h4><pre>aws ec2 run-instances --region us-east-1 --instance-initiated-shutdown-behavior terminate --image-id ami-00f44084952227ef0 --instance-type p2.xlarge --count 1 --security-groups &#39;***SECURITY GROUP***&#39; --iam-instance-profile Arn= &#39;***IAM PROFILE***&#39; --key-name &#39;***SSHKEY***&#39; --user-data &quot; $(cat &lt;&lt;- EOF #!/bin/bash sudo -H -u ec2-user /bin/bash &lt;&lt; UIS export CP=&quot;&quot;; export EMAIL=&quot;***EMAIL***&quot;; cd ~/; for jar in f-EH0t.jar oeH7t0.jar iJL-Pb.jar J3F7SB.jar pPr5X4.jar voMY9c.jar O7m0ey.jar YCN3tR.jar cSpzwv.jar RpCOEb.jar FNuYac.jar eDcqSl.jar C4HQIn.jar 8UOGP0.jar xtt19H.jar 1G14YH.jar 9es3XF.jar 48vRV5.jar 5h3bR6.jar pzeQN-.jar CRiDmT.jar 0JTCJX.jar uYIrM_.jar Z77u5Y.jar X6TsTs.jar 3YOsy4.jar a00s_L.jar pXz6c5.jar O4SgvD.jar V31sam.jar UMOLX5.jar _TXfJi.jar l3RN_h.jar xZL0n3.jar Oj8k9M.jar _YhFlX.jar 9t-Yau.jar baTLup.jar 9dzl-z.jar xdJiUB.jar YuOk8U.jar kutaq8.jar QNa5B1.jar 4Hokj2.jar Pwf130.jar 7G3g29.jar wjACoP.jar BEN_dU.jar NUQrWo.jar e1bjSZ.jar -eJmgW.jar fy4wUB.jar w5WtoP.jar _zHx5z.jar MIcjU_.jar BPGq9t.jar 6J3VYt.jar aF1S0g.jar 6HKE5E.jar 6E9PRl.jar 2u1fa8.jar N5gHDt.jar 3byqIm.jar bLRpy7.jar AGcHNa.jar OrqkJV.jar -tTGkl.jar r7lPxb.jar 45zjaX.jar rqYc2K.jar alIK-w.jar afqNFo.jar GMJhut.jar Ko2Hte.jar 8izKg9.jar EJfjGR.jar Vwf0Ra.jar 8mM1cU.jar QUxBO6.jar dROQuc.jar yJTzpW.jar pXGql3.jar hawbCt.jar bxr15w.jar nZykAJ.jar L1OY8r.jar 6K-JXg.jar Um0Kei.jar T0R9Td.jar Jx-25C.jar bdplSg.jar l9jVAn.jar QIfR2z.jar D0yETT.jar wRQbx9.jar tLZqts.jar 787x-K.jar peL8kP.jar 8ZVI59.jar mBrHXl.jar 6ZZOqI.jar wTLv11.jar XuFIvy.jar pMuNN6.jar bnHrjo.jar Wdf4w-.jar xT3K-m.jar DxeC-S.jar CL-vxy.jar j9VQK4.jar CLQBSL.jar -kbjMt.jar YJlxds.jar EHpifH.jar jEeVMf.jar BPujX7.jar dns2zS.jar GCOLwW.jar oQf5lQ.jar x-Ftxj.jar LyOrsV.jar 3_YOzw.jar jelh57.jar kyFLWy.jar AlBe8b.jar WfbARv.jar 4xCIr3.jar 01ltjy.jar MtpouU.jar G-kFuu.jar FLkR7U.jar g9gt1I.jar q4RYQK.jar OLbLHO.jar GqyKVU.jar qfW3YZ.jar lQR2uY.jar EB-wYY.jar 0xC6Ig.jar X5SZPT.jar 4v8-Zl.jar q1DWLy.jar ckSqtQ.jar Od5OE4.jar k3aZGU.jar Cd75fp.jar LeUAw6.jar yD32Lu.jar iMfwjc.jar 0Xfs_u.jar RkMYRs.jar S2mAFC.jar C4gLDS.jar f1JcA_.jar MnuHxO.jar VE5ZVR.jar TfkeL3.jar 9wOnFP.jar bClyca.jar pb-yJy.jar K6X5_x.jar v9yuH_.jar 9UqFEP.jar XlDla8.jar G89AJf.jar nH2y_H.jar W0AYwP.jar 9zEuTd.jar ljRMdY.jar UJTxfr.jar jYQE-O.jar cFwX2Y.jar uKNBE6.jar Sf901d.jar NLC2Wu.jar _IDgqr.jar G2ief4.jar mPrQWe.jar 2dTWnh.jar B9xTLu.jar bAcOV7.jar Ippim0.jar IlRtma.jar z3bW9S.jar 1i2_qH.jar 8qkh1L.jar wouHHS.jar FlF87r.jar vxX0tI.jar 9w-Q7U.jar Z45oIk.jar SiAfyj.jar QkVCiQ.jar yev-uh.jar pnNigj.jar DAZ-Yb.jar slFyWW.jar BSrZNy.jar 9QZEim.jar NPQo5o.jar VFxg8p.jar T5mocr.jar lcMRhs.jar IZdLkO.jar wI6J3m.jar ixUb09.jar ETY71Y.jar jrub1C.jar QWMip1.jar po1S0S.jar sLzt4c.jar yMrc3o.jar VQDDjF.jar n7wAL1.jar vettuO.jar wf3dUK.jar JXH-Vh.jar hAKEqe.jar Y-0SDz.jar xVJm_J.jar d4tJQE.jar Lvpyz6.jar 2RBz1r.jar 7Gr1L4.jar ULEMWE.jar I2JIzj.jar 7Inkfp.jar KlirFk.jar i7j6Lt.jar vL5_Ns.jar UU0JMd.jar qZEIAW.jar 8YoaFD.jar mlotDH.jar vUuxRe.jar k5ypeI.jar Ocjqhu.jar sWr959.jar 7OuRor.jar C5sqD5.jar 16qoWH.jar L7Hrbv.jar NT-7k2.jar T7DxJj.jar oACk12.jar cwlcUL.jar RHN28u.jar x9orXf.jar 7WQY7k.jar hsyZom.jar -Ky0UC.jar fEnNjl.jar uDwZQ6.jar DlYIoe.jar _JUO_a.jar i5kwu2.jar 7fPu29.jar FB_Xoq.jar aBm76Y.jar 6_PF5V.jar r6BCsX.jar 9Dteow.jar RWbct1.jar luFCcw.jar nIxI5Y.jar V8GNvw.jar KJB15I.jar TNVrLk.jar obfLK6.jar Z-cisn.jar qGvEiN.jar RiwJWf.jar CkblvJ.jar dlGiXs.jar j7uwVG.jar PpW_qM.jar UyIsWE.jar -w1_7J.jar 8RoAKp.jar 02i0qq.jar hybEFl.jar TtOfrv.jar keli5C.jar -4qEWQ.jar nUeNvL.jar 8F_lnk.jar K4uQoH.jar LqjYcm.jar kjTgGb.jar sLAk5j.jar HbKTAX.jar yl-4ID.jar cu_LeU.jar 8pcMuj.jar BCqwm6.jar AX7EiC.jar vXB4G1.jar s_AT99.jar g8--uE.jar OsusOe.jar SrpWaU.jar Ld8hJv.jar EudCbW.jar 5ehZVI.jar 1oXHZH.jar P2MFbV.jar FjibVP.jar 7U-SSe.jar ss88id.jar e5Tsvy.jar j44s1p.jar 1W2Ggj.jar Uz6USa.jar hxwJ2p.jar ORw1Ld.jar qJtmzz.jar fFkkQg.jar 2al7q_.jar jJhd5I.jar jUbTCj.jar H7uuLL.jar BoVsYH.jar fUNqU8.jar ysqQmE.jar G3JX2k.jar cwovNg.jar T9QB3u.jar 9UeJ4R.jar fRrTLe.jar gOnRy9.jar sAQVj6.jar l4rpcm.jar gqEM5x.jar U-HqwU.jar Xd4uu-.jar nuurqg.jar eV23hK.jar qbphll.jar jnZYPv.jar O9mbQu.jar xA0PIY.jar EZqsYZ.jar itjJIp.jar F1D5wz.jar NTz2or.jar IsN8Le.jar VoRcev.jar ako9s7.jar XhxkY0.jar Ny-ZJN.jar aJzzbY.jar xDhJAi.jar ZDulZk.jar MQ9YQT.jar IbpXV5.jar FKTWjX.jar 8hPHK2.jar EDleWl.jar MZxJpD.jar P3I3-1.jar UQUOWV.jar HP5OZp.jar 1QaL83.jar hj4Ywq.jar P3lwCp.jar GUOg7L.jar Fk0cKM.jar QZH8Yi.jar WYPR4u.jar g0c5E_.jar nN9lkW.jar k6zjpu.jar 38jQPy.jar iuCBfT.jar Lbmq4U.jar Vl35kt.jar UsU8bL.jar NYd0Xa.jar 2rtAul.jar m2RzmK.jar x38a_N.jar aOxpYf.jar xLEJ7a.jar cWF1cU.jar ft7dMy.jar wRvsn3.jar rSO0fK.jar aUTpvA.jar 7Oeu7r.jar VM42fS.jar sBEy6K.jar RqN1Ep.jar FWrTD7.jar Nb_zDS.jar O5SyiI.jar AyeI8I.jar ed5p6f.jar wcEww2.jar bkv_sz.jar 3FXtb-.jar lC1gse.jar r3WKBv.jar J9HZRM.jar O5gofE.jar I8lNUe.jar pCL-Y3.jar hz5ZA3.jar kERNCZ.jar iZ0rA1.jar viWbeG.jar w4kjgq.jar TXyAoe.jar Qtrz94.jar ixZc9Y.jar 5-grgh.jar OMj_95.jar mPNIe_.jar d1AdUp.jar IwRumF.jar 5lOGom.jar lWwzkw.jar 39NYcg.jar AjeEbr.jar I-jBja.jar dcy1VT.jar OkJn4B.jar UbjumV.jar KYJ46i.jar vpLrIy.jar sLM2YL.jar gP-Xqu.jar y8Ddmn.jar G_myC0.jar jIi5Q_.jar QulA1d.jar JZ4M09.jar 3TMMZe.jar S0dsWf.jar mByV44.jar djNzzp.jar SI8fq8.jar uGSIEH.jar T9JkbX.jar zlePMY.jar toffcP.jar n2_bZH.jar Elk3G-.jar AiPjaz.jar HKectW.jar -GVJrL.jar 9Ex4aM.jar fjMR70.jar 44-gTw.jar X3fVGz.jar TVwWkw.jar 91MK_J.jar JfzZM4.jar hpAuYP.jar ZfW8Ih.jar H53QWp.jar FQod1j.jar q-i-cN.jar mDZVCn.jar aU9RBm.jar HYPfFq.jar 1ypx5P.jar A3EfuH.jar W3MNl-.jar ly-Ejh.jar vmStrx.jar nQPfR1.jar ARgIYk.jar vSaZxl.jar bLrEiw.jar; do export FILE=&quot;~/lib/\\\$jar&quot;; aws s3 cp &quot;s3://symmetry.deepartist.org/lib/\\\$jar&quot; \\\$FILE; export CP=&quot;\\\$CP:\\\$FILE&quot;; done nohup java -DMAX_FILTER_ELEMENTS=268435456 -Dspark.master=local[4] -Dtendril.sessionId=76ace435-1ee6-4122-ac1b-48f185487783 -DMAX_IO_ELEMENTS=268435456 -Dtendril.bucket=symmetry.deepartist.org -DMAX_DEVICE_MEMORY=11811160064 -Dtendril.keyspace=lib/ -Dtendril.localcp=~/lib/ -DCUDA_DEFAULT_PRECISION=Float -DMAX_TOTAL_MEMORY=11811160064 -cp \\\$CP com.simiacryptus.aws.S3TaskRunner &amp; UIS EOF ) &quot;</pre><h3>Coding Setup</h3><p>If you use AWS, but lack the hardware to run this yourself, you can still easily customize the source code and play with whatever you like. You can compile the project locally and have it deploy to AWS and run there nearly automatically. If you look at the source code in <a href="https://github.com/SimiaCryptus/examples.deepartist.org">https://github.com/SimiaCryptus/examples.deepartist.org</a> , you will see that there are traits on the executable objects. Some traits, such as LocalRunner, cause the application to run locally. If the P2_XL trait is used the application will instead start an ec2 instance, upload itself to that host, then run the application there. (This requires that your environment is configured with appropriate AWS credentials.)</p><h3>Running Locally</h3><p>Of course, AWS is not required in order to use this tool. If you have the necessary Hardware, you can run this locally. All that is required is the NVidia CUDNN, CUSparse, and Cuda libraries. These are all free, though you will need to sign up for an NVidia developer’s account, which is also free. Once installed, if your machine has the resources, the applications will run locally using the LocalRunner trait.</p><h3>Further Reading</h3><p><a href="http://symmetry.deepartist.org/">http://symmetry.deepartist.org/</a> — This site collects all the working copies of notebooks I’ve run in preparation for this paper.</p><p><a href="https://github.com/SimiaCryptus/examples.deepartist.org">https://github.com/SimiaCryptus/examples.deepartist.org</a> This is the code for implementing the notebooks both in the examples gallery and in the symmetry gallery.</p><p><a href="https://github.com/SimiaCryptus/all-projects/tree/master/mindseye">https://github.com/SimiaCryptus/all-projects/tree/master/mindseye</a> — These are the main code projects used to implement the AI used to generate these examples.</p><p><a href="http://gallery.deepartist.org/">http://gallery.deepartist.org/</a> — Another site I maintain of manually curated AI-produced images</p><h3>Neural Networks</h3><p><strong>OpenAI Microscope</strong> — <a href="https://microscope.openai.com/models">https://microscope.openai.com/models</a> — This is a catalog of the textures produced by maximizing the response of each neuron for a wide variety of open source networks.</p><p><strong>Deep Dream</strong> — <a href="https://ai.googleblog.com/2015/07/deepdream-code-example-for-visualizing.html">https://ai.googleblog.com/2015/07/deepdream-code-example-for-visualizing.html</a> — This is the original Deep Dreap paper, which heralded in this age of deep learning art.</p><p><strong>Deep Style Transfer</strong> — <a href="https://arxiv.org/abs/1508.06576">https://arxiv.org/abs/1508.06576</a> — Another important paper, describing the style transfer technique which forms the basis for the techniques described in this paper.</p><p><strong>Escher’s Online Gallery</strong> — <a href="https://mcescher.com/gallery/">https://mcescher.com/gallery/</a> — The official online gallery of MC Escher’s art</p><p><strong>DeepDreamGenerator.com Gallery</strong>- <a href="https://deepdreamgenerator.com/#gallery">https://deepdreamgenerator.com/#gallery</a> — An online gallery of art produced by a commercial service</p><p><strong>DeepArt.io Gallery</strong> — <a href="https://deepart.io/latest/">https://deepart.io/latest/</a> — Another online gallery of art produced by a commercial service</p><h3>Geometry and Mathematics</h3><p><a href="https://en.wikipedia.org/wiki/Tessellation"><strong>Tessellation</strong></a> — This branch of mathematics deals with how to divide space, for example into regular polygons. It studies repeating patterns that are the basis for tiled textures.</p><ol><li>Regular tilings: <a href="http://www.weddslist.com/groups/genus/1/">http://www.weddslist.com/groups/genus/1/</a></li><li><a href="https://en.wikipedia.org/wiki/List_of_tessellations">List of tessellations</a></li></ol><p><strong>Group Theory</strong> — This branch studies important types of symmetry and order</p><ol><li>Color Permutation Groups — <a href="https://en.wikipedia.org/wiki/Permutation_group">Permutation group</a></li><li>Symmetry on a Sphere — <a href="https://en.wikipedia.org/wiki/Polyhedral_group">Polyhedral group</a></li><li>Point Groups — <a href="https://en.wikipedia.org/wiki/Point_groups_in_three_dimensions">Point groups in three dimensions</a></li></ol><p><a href="https://en.wikipedia.org/wiki/Hyperbolic_geometry"><strong>Hyperbolic geometry</strong></a> — The antithesis of spherical geometry, hyperbolic geometry is a very specialized but interesting subject in mathematics.</p><ol><li><a href="https://en.wikipedia.org/wiki/Projective_geometry">Projective geometry</a></li><li><a href="https://en.wikipedia.org/wiki/Poincar%C3%A9_disk_model">Poincaré disk model</a></li><li><a href="https://en.wikipedia.org/wiki/M%C3%B6bius_transformation#Hyperbolic_space">https://en.wikipedia.org/wiki/M%C3%B6bius_transformation#Hyperbolic_space</a></li></ol><p><em>Originally published at </em><a href="http://blog.simiacryptus.com/posts/symmetric_textures/"><em>http://blog.simiacryptus.com</em></a><em> on January 31, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be674ecb7190" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/geometric-symmetry-in-deep-texture-generation-be674ecb7190">Geometric Symmetry in Deep Texture Generation</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create your own deep neural art with DeepArtist.org]]></title>
            <link>https://acharneski.medium.com/create-your-own-deep-neural-art-with-deepartist-org-bf0992d00142?source=rss-b5d0d73f6aa4------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf0992d00142</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[style-transfer]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Andrew Charneski]]></dc:creator>
            <pubDate>Mon, 02 Sep 2019 05:38:14 GMT</pubDate>
            <atom:updated>2019-09-02T14:12:32.267Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*mvl8hYdwJNUD-jh1" /><figcaption>An animated free-form texture featuring rotational symmetry generated by <a href="http://examples.deepartist.org">examples.deepartist.org</a></figcaption></figure><p><a href="https://github.com/SimiaCryptus/deepartist.org/blob/master/examples.deepartist.org">DeepArtist.org</a> is an image processing platform using convolutional neural networks to perform state-of-the-art image processing techniques. This software is targeted at hobbyists and digital artists, and as such this project is focused on the practical tools provided to produce pretty pictures. To run locally you need a recent <a href="https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#prerequisites-windows">Nvidia GPU</a>, but you can also run these tasks on <a href="https://aws.amazon.com/machine-learning/amis/">Amazon EC2</a>.</p><p>In contrast to many contemporary AI projects, this project uses Scala, not Python. I have attempted to simplify things so that very little programming literacy at all is required, and the learning curve is friendly to beginners who want to experiment. One benefit of this approach is that this software runs easily on a variety of systems, including Windows and Mac desktops and on the Cloud.</p><p>As you will quickly discover, these painting processes have many controls and settings and can be customized in countless ways. Getting an ideal image result may require quite a bit of experimentation, and you will need a way to track this work. Additionally, you may develop new artistic pipelines, and you may wish to share them. To support these types of workflows, DeepArtist applications output rich text and images as output and have them automatically built into a static website on s3.</p><p>A key part of DeepArtist.org are <a href="https://github.com/SimiaCryptus/examples.deepartist.org">the examples</a> — A set of starting applications that use the platform to demonstrate the basis image processing techniques and concepts.</p><h3>Development Software</h3><p>First, there are some basic tools needed to run this software:</p><ol><li><a href="https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html">Java</a> — You probably have some version of Java, but you will need to install a Java Development Kit so you can compile and run the code. There are several distributions of JDK, many freely available. I use Oracle’s JDK 8.</li><li><a href="https://git-scm.com/downloads">Git</a> — Several friendly distributions and interface wrappers exist for Git, but I prefer the basic command line. You can probably get away without this if you use the IntelliJ git plugin.</li><li><a href="https://www.jetbrains.com/idea/download/#section=windows">IntelliJ</a> — You don’t technically need a fancy development environment, but this is free and well worth this disk space. IntelliJ provides a “community edition” which has basically all the Java features you will need to run this software and develop with it. I used the free version to develop almost all of this software.</li></ol><h3>GitHub</h3><p>If you aren’t a member of Github, I recommend <a href="https://github.com/join">signing up for a free account</a>. You can then “fork” <a href="https://github.com/SimiaCryptus/examples.deepartist.org">examples.deepartist.com</a> so you can have your own copy to customize.</p><p>I also recommend you install and configure the Intellij github plugin: <a href="https://www.jetbrains.com/help/idea/github.html">https://www.jetbrains.com/help/idea/github.html</a></p><h3>cuDNN</h3><p>If you want to run jobs locally, and you have a good NVidia GPU, you will need to install cuDNN (CUDA Deep Neural Network Library). If you are not running jobs locally, Amazon Deep Learning instances come with this library pre-installed. Though downloading is free, unfortunately, NVidia has yet to make a public release of this library and requires an NVidia developer membership. Fortunately, this is free to sign up for.</p><h3>AWS</h3><p>AWS is used (optionally) for storing results, serving them as a website, and for executing jobs themselves. An AWS account in itself is free, and you pay for pretty much exactly what you use, but you can still rack up a bill fast if you don’t keep an eye on it. If you want to use it, you will need to sign up for an account, install the command line tools, and establish environment credentials.</p><h3>Running the Project</h3><p>Now that the basics are setup, we will download and load the examples project on your system:</p><ol><li>Clone the <a href="https://github.com/SimiaCryptus/examples.deepartist.org">examples.deepartist.org</a> repo</li><li>Open IDE and Import the project</li></ol><p>We are now ready to run our first project. To simplify things, let’s run a very basic project that doesn’t use any neural networks. Open the examples project and then open the <a href="https://github.com/SimiaCryptus/examples.deepartist.org/blob/master/src/main/scala/com/simiacryptus/mindseye/art/examples/BasicNotebook.scala#L33">BasicNotebook</a> class.</p><ol><li>Open the object and run it — Right click the file and choose “run”</li><li>Load page, confirm configuration — Open a browser to <a href="http://localhost:1080/">http://localhost:1080/</a>. The initial page will prompt the user to edit the settings of the job. You can edit the text to be rendered, the size, the target s3 bucket, and many other settings in other jobs</li><li>Refresh and upload image — Assuming the content url was left intact, the job will (upon refreshing the page) prompt you to upload an image. Upload one.</li><li>Wait for completion — One the upload completes, the job runs. This job is fast and will complete in seconds.</li><li>Examine results — The results will have been saved in a local /reports/ directory that is noted in the output logs, and if setup also on S3.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*ZfmFApqo7pa4cjS_" /><figcaption>An example result from the BasicNotebook job</figcaption></figure><h3>Advanced Features</h3><p>Things don’t always go as planned, and sometimes you want to do something other than pressing “Run”. This section describes some of these common scenarios</p><p><strong>If you have to interrupt a job for any reason</strong>, you may want to be able to continue painting where you left off. This is possible by saving the latest image provided via http, and using that image to upload as the initial canvas url.</p><p><strong>Any job can be run locally or on EC2.</strong> Most jobs are by default coded to run locally, but by modifying or adding a new object which derives from the same class, you can configure the EC2 deployment code. This will use your environment credentials to start a new AWS EC2 instance, upload all the needed code, and remotely start the application. When running, you can manage it via http just as in local execution, and additionally it will send you emails at the start and end of the job run. Watch your execution times! These are Deep Learning instance types, with a high amount of power that comes with a noticeable price tag.</p><p>When you run for the first time, you will be prompted to enter your email via stdin, and the role used to start the instance will likely not have all the needed permissions, for example to write to the s3 bucket you intend to publish to. It is recommended that during this first execution, you log into the AWS console and manually assign any needed permissions to the newly created role.</p><p><strong>Many important settings can be configured via property overrides</strong> on the job classes. Of particular note are:</p><ol><li>Bucket — Most users will want to configure the bucket field to be something they have access to write to</li><li>Http port — If you want to use a port other than 1080, you can override it via the http_port field</li></ol><p>Another important config, which is settable via a java property, is the AWS region to use. To use something other than the default us-east-1, simply set the AWS_REGION property e.g. by adding the execution argument -DAWS_REGION=us-west-2</p><p>Once an application is running, there are several other pages that can be requested for helpful information:</p><ol><li>/cuda/info.txt — This endpoint returns diagnostics text that is returned by the CuDNN library</li><li>/shutdown — This endpoint immediately kills the JVM, and if running on EC2 also triggers instance termination.</li><li>/threads.json — This endpoint returns information on all stack traces and various thread information from the JVM. Useful for internal code development.</li><li>/cuda/stats.json — This endpoint returns profiling data collected during CuDNN invocations. Useful for internal code development.</li></ol><h3>See Also</h3><p>This software is built on top of other software and technology.</p><ol><li><a href="https://developer.nvidia.com/cudnn">CuDNN</a> and CUDA — Nvidia publishes many useful number-crunching libraries that take advantage of the parallel computing abilities of its GPUs. CuDNN in particular is the preferred acceleration library used by deepartist.org.</li><li><a href="https://www.tensorflow.org/">TensorFlow</a> — Google’s AI research team has open-sourced Tensorflow, a portable runtime for expressing and running neural networks. This library can be used for importing vision pipelines into DeepArtist.org, such as the pre-packaged Inception model.</li><li>Java and <a href="https://www.scala-lang.org/">Scala</a> — Java is arguably the most popular programming environment today. Scala runs within the Java environment as an alternate language, and is one of the most expressive languages available. Both have a host of free, world-class tools available.</li></ol><p>Additionally, the methods demonstrated by this project were overwhelmingly based on some well-known deem image processing algorithms:</p><ol><li><a href="https://ai.googleblog.com/2015/06/inceptionism-going-deeper-into-neural.html">Deep Dream</a> — In 2015 Google Research published Deep Dream, which demonstrated a use of convolutional neural networks to produce interesting visual effects.</li><li><a href="https://arxiv.org/abs/1508.06576">Deep Style Transfer</a> — In 2016 researchers published a style transfer algorithm using convolutional neural networks, whose approach inspires the bulk of the processing methods used by DeepArtist.org</li></ol><p>Research into AI requires verifiable research, and to aid that many papers include published pretrained models. These pretrained models can be imported so that the latent patterns they have learned can be used in image processing. At the time of publishing, DeepArtist.org has 3 pre-packaged pipelines which are automatically downloaded upon usage:</p><ol><li><a href="https://arxiv.org/abs/1409.1556">VGG16 and VGG19</a> — These are large, very simple networks using a series of simple convolution, pooling, and activation layers. As it turns out, the dense and simple structure of these networks seem to provide much better behavior for image processing.</li><li>Inception — A sample import of a tensorflow model, a pretrained inception model is also provided. It uses a more complicated structure to perform well at it’s primary task, classification, with a much smaller size (and a faster speed).</li></ol><h3>Examples.DeepArtist.org</h3><p><a href="http://Examples.DeepArtist.org">There are a number of examples released with deepartist.org</a> which attempt to illustrate the concepts of these techniques and the capabilities of this software. These examples are free to use as starting points for any of your art projects. Each example is published to the site as a full example report, with details, code, links, and further images in each.</p><h3>Textures &amp; Core Concepts</h3><p>The basic setup for a deep painting is that you have a canvas, which can be modified at will by the AI process, to match a particular signal. This signal matching network consists of a filter, which modifies the image into more abstract data, and then a loss function which measures how close that data signal is to a reference (i.e. style) signal. These filters and operators can then be scaled and combined to form a limitless variety.</p><p>A pipeline is a pre-trained deep vision network which is loaded and made available as a series of image processing layers. Each layer builds on the last to extract higher-level details from the source image. This can be illustrated by this example which surveys the sequence of layers in the VGG19 pipeline, using each layer to reconstruct a target signal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*O15v_zuZMvRLf3Ze" /></figure><p>You can also configure operators, which define how close a signal is to the objective. This objective may be some kind of “similarity measure” to compute how close one image is to another, and many such measures exist; these approach zero. Others simply seek to increase a measure, for example rms “power” as used in DeepDream, possibly with some cutoff before infinity. A survey example of them displays the varied effects:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*jNODZCMKJv84yiti" /></figure><p>When a painting process is begun, there must be some data on the canvas to start with. Interestingly, a completely blank canvas produces poor results, due to something called “symmetry breaking”. There are three main types of seed used in deepartist.org: Noise, Plasma, or Image. Noise is simple random white noise, which can be scaled and offset. (For that matter, scaling and offset syntax is available for all image input urls) Plasma is a simple algorithmic texture that resembles a randomly-colored cloud. An actual image can also be given, either as an upload or as a literal url. This example displays a survey of these seed types when used to paint with the same texture parameters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*luu6yOJCzacDzPCd" /></figure><p>As you may note, starting from the image results in something that looks like style transfer. This isn’t so much style transfer as warping the content image until it resembles the desired style. Among other differences, it tends to be deterministic — if you run it 3 times, you get nearly the same 3 results.</p><p>Another important factor in the painting process is what resolution we perform it at. As anyone who’s fallen from orbit knows, things look a lot different depending on how far away you are. This variety manifests itself in our painting process by the operative resolution, of what resolution we do a painting operation at. You can see the variety caused by the same painting parameters being performed at small scale, at large scale, and using intermittent stages in this example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*0MoH9nzlfjLnJTPp.gif" /></figure><p>Growing a texture from a smaller image results in a naturally more complex and varied large structure, whereas initial painting using a higher resolution typically produces a more uniform look.</p><p>This can be further modified by attaching additional filters to the vision pipeline layers, such as in these examples:</p><p><strong>Tiled Texture Generation</strong> — By wrapping the canvas around itself to enlarge it, we learn to paint regardless of these wrapping boundaries, and will get a tileable image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hqD1GS8A7UF0ENlL" /></figure><p><strong>Kaleidoscope (Rotational Symmetry and Color Permutations)</strong> — A layer which reflects and rotates space (and color space) can produce an image with a guaranteed symmetry. This can be combined with the tiling layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NtaFaT4p4jDL6mEu" /></figure><p>Additionally, the resulting canvas can be post-processed by any other function. One fun example of this is the stereogram generator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FqVaJKz-fENd_4vS" /></figure><h3>Style Transfer</h3><p>Depending on your religion, you may wish to paint a painting to resemble some object or scene. If you insist on your graven images, you can use the content matching operators. These are handled slightly differently than the style operators, but are fully illustrated by the following examples.</p><p>Content images can be reconstructed by signal matching using any vision layer, in the same manner as style matching. Each level higher conveys less local information, such as color, and more higher-level information such as patterns. You can see this in the following survey, which uses each layer in a pipeline to reconstruct target content without any further modifiers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*bS4gzPmhNt9aDfq8" /></figure><p>When these content operators are combined with style operators, we can demonstrate classic deep style transfer, such as in this example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZuUxFLblz5EMgnQ_" /></figure><p>For high-definition results, multiple phases of style transfer processes can be used while progressively enlarging the canvas. By fine-tuning the parameters for each resolution, we can gain better control over the result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wHwsFurEdj72Aos3" /></figure><h3>Animations</h3><p>There are images, there are videos, and in between there are animated gifs. Animated GIFs are one speciality of DeepArtist.org.</p><p>A variety of animations have already been shown, wherein we survey a variety of treatments, and combine them with labels into an animation.</p><p>Another type of animation is to sweep a range of parameters. One example provided is a style transfer sweep from one style to another:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*obgj-D4624zBy5BV" /></figure><p>Why start with white noise when we do a style transfer? Wouldn’t it be faster to start with the content image itself and change it to match the desired style? One reason is that this heavily biases the result in a way you will have trouble controlling, but another is that the result is deterministic. If we start with noise, there is an inherent randomness to our resulting image that makes it unique. If we use this randomness to produce an animation, we get a unique jittery effect:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*Ra05BsYWaHuP28LA" /></figure><p>This can also be combined with kaleidoscopic textures, as seen in image at the top of this article.</p><p>Enjoy!</p><p><em>Originally published at </em><a href="https://blog.simiacryptus.com"><em>https://blog.simiacryptus.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf0992d00142" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MindsEye Artist’s Kit]]></title>
            <link>https://acharneski.medium.com/mindseye-artists-kit-170337ba41be?source=rss-b5d0d73f6aa4------2</link>
            <guid isPermaLink="false">https://medium.com/p/170337ba41be</guid>
            <category><![CDATA[deepdream]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[style-transfer]]></category>
            <category><![CDATA[computer-art]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Andrew Charneski]]></dc:creator>
            <pubDate>Tue, 24 Apr 2018 02:19:05 GMT</pubDate>
            <atom:updated>2018-04-24T04:33:57.091Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello! Today we’ll be learning about the <a href="https://github.com/SimiaCryptus/mindseye-art">MindsEye Artist’s Kit</a>, a simple way for nearly anyone to produce their own deep learning artwork! Our goal here is to make this easy to use and simple to set up, using remote execution on Amazon EC2 to negate special hardware requirements. Only basic software skills, or a willingness to learn, are needed.</p><p>Although EC2 is a paid service, the prices are economical. We use <a href="https://aws.amazon.com/ec2/instance-types/p3/">P3.2XL</a> instances, which cost about a nickel per minute. However, if you consider that this instance seems to perform almost 20x faster than my desktop, the $3 for an hour of compute on this machine is comparable to the $2–3 dollars of energy my home machine costs per day (A 1kW PC running at 100% for 24 hours at $0.12 per kW*hr — typically machines use power savings when idling or sleeping.) However, even though the price is reasonable and even though the software covered here does its best to clean up the instances after use, it is a good idea to double-check the <a href="https://aws.amazon.com/console/">AWS console</a> to make sure you haven’t left any machines on when you are done!</p><h3>Art Examples</h3><p>What kind of images can we generate with this project? Here are a few examples. Keep in mind these are fairly raw first-generation examples. Your work could be way cooler, and I can’t wait to see it!</p><ul><li>This high-resolution image of the Earth has been processed using the Deep Dream algorithm, which enhances latent patterns found in the image:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4LTMitzZq_oihsZ2.png" /></figure><ul><li>Here is an animation of several different style transfer results, each inspired by the style of a different painting, each rendering a content image of the Taj Mahal:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*0zp9nLx1Tckua4Qm.gif" /></figure><ul><li>Abstract textures, with optional support for tiling, can also be generated:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*TSTiJSagT2OoXTiz.png" /></figure><ul><li>These techniques can also be hybridized to create computer-generated abstract art:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/0*eSibyUBSXa78RIrP.gif" /></figure><h3>Background</h3><p>At the fundamental level, we are using Neural Networks. Neural Networks are an artificial intelligence technique inspired by the biological brain found inside most humans. Each Neuron individually processes only a tiny amount of data, but through many layers of interconnections more advanced behaviors can emerge. The mechanics of a single layer of neurons work largely on the principles of Linear Algebra, and the network is generally trained using Back Propagation.</p><p>When processing visual data, however, we can take advantage of self-similarity within the data: A shape in the upper-left of the image is still the same shape even if it is in the lower-right in another image. Pixels which are next to each other tend to be of the same color. These spatial relationships allow us to impose this symmetry on the network itself, creating what is known as a convolutional network. Convolutional networks are great at processing image data and have been known to pick out edges, textures, and shapes at increasing levels of complexity.</p><p>One of our standard networks is VGG19, a pre-trained model <a href="https://arxiv.org/pdf/1409.1556.pdf">built by some researchers at Oxford</a> to process the <a href="http://www.image-net.org/challenges/LSVRC/2014/">ImageNet Challenge 2014</a> image recognition dataset. This “deep” convolutional network consists of 20–70 layers, depending on how you count them, and is nearly a gigabyte in size. This network was pre-trained for image classification, but we are going to re-use it for art generation by extracting the first few layers as “feature detection layers”. These first layers have implicitly been trained to respond to details that a relevant to object detection, with the idea that these details will also be the details of importance in the human visual processing system.</p><p>One of the first creative uses for these feature layers was the <a href="https://research.googleblog.com/2015/06/inceptionism-going-deeper-into-neural.html">Deep Dream algorithm</a>. This method modifies an image seeking to maximize the L2 norm of the activation of a given layer. This maximizes the signal of a given layer, thus whatever textures that layer was detecting should be visually enhanced. This can also use a weighted combination of the signal strengths of multiple layers, providing some control over the result.</p><p>A <a href="http://genekogan.com/works/style-transfer/">more flexible method</a> uses an input “style” image to gather inspiration from. This style image is pre-processed by the feature layers, and then we collect metrics about these signals. Specifically, we track the mean value of each feature channel (similar to a color channel, but representing a larger “thing” such as a texture or a shape) and the mean of all cross-products, technically known as a Gram Matrix. By recording these metrics and then optimizing an image to have similar metrics, we can encourage any input image to have a similar distribution of shapes and textures; i.e. style transfer!</p><p>This is of course only a very, very brief theoretical overview. There are many other pre-trained networks out there, and there are many variations to these techniques. There is nearly an endless potential here for mathematically-based creativity!</p><h3>Requirements</h3><p>By using EC2 and Java, we can reduce the requirements for running this project down to commonly available and free components. These requirements are largely the same as for any Java software project:</p><ol><li>An active <a href="https://aws.amazon.com/"><strong>AWS</strong></a><strong> account</strong>, with root user and/or full permissions. This account itself is free to sign up for, though the machine time is a paid resource.</li><li><strong>AWS </strong><a href="https://aws.amazon.com/cli/"><strong>Command Line Tools</strong></a> — Used to configure the local AWS credentials.</li><li>A <a href="https://git-scm.com/"><strong>Git</strong></a><strong> client</strong> — Used to retrieve and manage the code for this project.</li><li><a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html"><strong>Java 8+ JDK</strong></a> — Code is built locally and deployed automatically, so you need the tools to build Java.</li><li><a href="https://www.jetbrains.com/idea/download/"><strong>IntelliJ</strong></a> (or compatible tool such as <a href="http://www.eclipse.org/downloads/eclipse-packages/">Eclipse</a> or <a href="https://maven.apache.org/">Maven</a>) — Needed to open, build, and run the project. Further instructions assume the reader is using IntelliJ.</li></ol><h3>Environment Setup</h3><p>First, let’s assume you don’t have all the requirements installed. All you have is a computer, the internet, an email address, a web browser, and a credit card. No problem! You just need to setup 3 main things:</p><p><a href="https://aws.amazon.com/"><strong>Amazon Web Services</strong></a> provides cloud computing facilities, including <a href="https://aws.amazon.com/ec2/instance-types/p3/">state of the art hardware</a> for <a href="https://aws.amazon.com/machine-learning/amis/">Deep Learning with CuDNN</a>.</p><ol><li><a href="https://aws.amazon.com/free/">Sign up</a> for an AWS Account</li><li>Install the <a href="https://aws.amazon.com/cli/">AWS Command Line Tools</a></li><li><a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html">Configure the user login for your system</a></li></ol><p><strong>Git</strong> is a popular peer-to-peer version control system used to manage source code.</p><ol><li>Make a <a href="https://github.com/join">free Github Account</a> — This is needed to fork the mindseye-art project, if you want to post your own code modifications online.</li><li>Install a <a href="https://git-scm.com/">Git client</a> — This is needed to download the mindseye-art project.<br>Alternately, <a href="https://desktop.github.com/">GitHub</a> provides a nice graphical user interface client.</li></ol><p><strong>Java Development Tools</strong> are needed, including:</p><ol><li><a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html">Java 8 JDK</a> — The Java Development Kit is used to build Java source code</li><li><a href="https://www.jetbrains.com/idea/download/">IntelliJ</a> — The community edition is free and works great; Mindseye was developed using it.</li></ol><h3>Project Setup</h3><p>Pulling the project is as simple as any other Java project:</p><ol><li><a href="https://github.com/SimiaCryptus/mindseye-art/fork">Fork the project</a> — This lets you publish your own work. This is optional and you can do it later, but it is easier to do as step #1.</li><li><a href="https://help.github.com/articles/cloning-a-repository/">Clone the project</a> — Use Git to download the project to your machine</li><li><a href="https://www.jetbrains.com/help/idea/maven-support.html#maven_import_project_start">Load the project in IntelliJ</a> — This will download all other dependencies</li></ol><h3>Execution</h3><p>Execution of any script is easy:</p><ol><li>Select a script — for example, <a href="https://github.com/SimiaCryptus/mindseye-art/blob/a18e37a640d7754c9067b8a2fb38356ff65f41d2/src/main/java/com/simiacryptus/mindseye/deep_dream/Simple.java">com.simiacryptus.mindseye.deep_dream.Simple</a></li><li>Edit the script if desired, for example by editing these common parameters:<br><a href="https://github.com/SimiaCryptus/mindseye-art/blob/a18e37a640d7754c9067b8a2fb38356ff65f41d2/src/main/java/com/simiacryptus/mindseye/ImageScript.java#L29"><em>Verbosity</em></a><em> </em>— If set to true, the report will include details of the training process used to generate the images.<br><a href="https://github.com/SimiaCryptus/mindseye-art/blob/a18e37a640d7754c9067b8a2fb38356ff65f41d2/src/main/java/com/simiacryptus/mindseye/ImageScript.java#L30"><em>Max Iterations</em></a><em> </em>— Sets the maximum number of iterations used in each training phase<br><a href="https://github.com/SimiaCryptus/mindseye-art/blob/a18e37a640d7754c9067b8a2fb38356ff65f41d2/src/main/java/com/simiacryptus/mindseye/ImageScript.java#L31"><em>Training Minutes</em></a><em> </em>— Sets the maximum number of minutes used in each training phase<br><a href="https://github.com/SimiaCryptus/mindseye-art/blob/a18e37a640d7754c9067b8a2fb38356ff65f41d2/src/main/java/com/simiacryptus/mindseye/deep_dream/Simple.java#L56"><em>Input Image</em></a><em> </em>— Each of these scripts use one or more input images<br><a href="https://github.com/SimiaCryptus/mindseye-art/blob/a18e37a640d7754c9067b8a2fb38356ff65f41d2/src/main/java/com/simiacryptus/mindseye/deep_dream/Simple.java#L51"><em>Output Resolution</em></a> — The resolution of the output image. Most scripts will risk running out of memory at a resolution of around 1000px — The HiDef script variants should be used to deal with this limit.</li><li>Run <a href="https://github.com/SimiaCryptus/mindseye-art/blob/a18e37a640d7754c9067b8a2fb38356ff65f41d2/src/main/java/com/simiacryptus/mindseye/deep_dream/Simple.java#L96">EC2 entry point</a> — In IntelliJ, you can right click the EC2 inner class and select “Run Simple$EC2.main()”</li></ol><h3>First Time Setup</h3><p>When run, the EC2Runner class looks for user-settings.json and ec2-settings.json, and if they are not found it starts a bootstrapping process to initialize itself. This is mostly automated, as long as the user has full permissions to AWS setup properly.</p><p>First, the user is prompted for email via standard input. There is no gui for this, so simply type your email into the console window and press enter. This email will be verified via AWS, sending an email to the provided address requesting confirmation to enable messages.</p><p>Next, <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html">using the aws user configured via the cli</a>, the application sets up various AWS entities to support execution including:</p><ol><li><em>S3 Bucket</em> — This stores published results and code deployed to EC2</li><li><em>IAM role</em> — A non-administrative role is configured for the EC2 node</li><li><em>EC2 Security Group</em> — Configures networking security</li><li><em>SSH Keys</em> — Used to control the EC2 node once launched</li></ol><h3>Monitor Execution</h3><p>Once the initialization logic completes, the remote process is launched. This is a complex, multi stage process involving launching a new EC2 instance, connecting to it, deploying code, and managing remote execution. This is largely transparent to the user, who will monitor the process over these stages:</p><ol><li>Browser Windows Open — The process will open two browser windows; the first deploys the logged progress of the local process, which dispatches the remote task. The second browser window opens after the remote process has been started, and displays the output of the main script being remotely run.</li><li>A “Start” Email is Sent — The user is notified by email with links to monitor output progress and to manage the node in the AWS Console.</li><li>A “Finished” Email is Sent — This email includes the full output of the script, with appended links to the HTML, PDF, and ZIP formatted results.</li></ol><p>At the end of execution, the instance should automatically shut down. It can also be manually terminated by using the AWS Console, linked to in the “start” email.</p><p>The MindsEye Artist’s Kit includes a variety of starter scripts, currently available in 3 families and 5 sub-types:</p><h3>Script Families</h3><p><a href="https://github.com/SimiaCryptus/mindseye-art/tree/a18e37a640d7754c9067b8a2fb38356ff65f41d2/src/main/java/com/simiacryptus/mindseye/deep_dream"><strong>Deep Dream</strong></a> — This process enhances latent patterns within an input image. This script uses the following parameters:</p><ol><li>Content Image — A single input image is given, which is input directly and gradually altered.</li><li>Per-layer “mean” coefficient — These coefficients anchor the result to the original content by providing a penalty for L2 deviations from the ground-truth signal at a given layer.</li><li>Per-layer “gain” coefficient — These coefficients determine the strength of amplification for each layer’s signal</li></ol><p><a href="https://github.com/SimiaCryptus/mindseye-art/tree/a18e37a640d7754c9067b8a2fb38356ff65f41d2/src/main/java/com/simiacryptus/mindseye/style_transfer"><strong>Style Transfer</strong></a> — This combines two images, using the content of one image and the style of another to render a unique combination of the two. This script uses the following parameters:</p><ol><li>Content Image — The primary input image determines the content. This is first passed through a degradation process to initialize the output image, which is then evolved using the feature signals of the undegraded input.</li><li>Style Image — One or more images style images are also input; these are pre-processed to gather aggregate metrics which describe the overall patterns and textures contained within.</li><li>Per-layer “mean” coefficient — These coefficients determine how tightly to match the mean values of each feature channel on the given layer with the target style.</li><li>Per-layer “cov” coefficient — These coefficients determine how tightly to match the Gram matrices of each feature channel on the given layer with the target style.</li><li>Per-layer “gain” coefficient — These coefficients add the components used in Deep Dream, causing signal amplification at each layer where set.</li></ol><p><a href="https://github.com/SimiaCryptus/mindseye-art/tree/a18e37a640d7754c9067b8a2fb38356ff65f41d2/src/main/java/com/simiacryptus/mindseye/texture_generation"><strong>Texture Generation</strong></a> — Very similar to style transfer, this process lacks a content image and thus generates abstract imagery. This script uses the following parameters:</p><ol><li>Style Image — One or more images style images are input; these are pre-processed to gather aggregate metrics which describe the overall patterns and textures contained within.</li><li>Per-layer “mean” coefficient — These coefficients determine how tightly to match the mean values of each feature channel on the given layer with the target style.</li><li>Per-layer “cov” coefficient — These coefficients determine how tightly to match the Gram matrices of each feature channel on the given layer with the target style.</li><li>Per-layer “gain” coefficient — These coefficients add the components used in Deep Dream, causing signal amplification at each layer where set.</li></ol><h3>Script Sub-Types</h3><p>Each family of script is provided in several forms, each supporting a slightly different use-case:</p><ol><li><strong>Simple </strong>— An example is provided that is as simple as possible, using a single phase and a single set of inputs.</li><li><strong>Enlarging </strong>— The basic process is repeated over several iterations, between which the working image is gradually enlarged. This can provide new behavior, for example by combining multiple scales and resolutions.</li><li><strong>ParameterSweep </strong>— This repeats the basic process over a range of input parameters, displaying the resulting progression as a formatted table and as an animation.</li><li><strong>StyleSurvey </strong>— Only applicable to Style Transfer and Texture Generation, this script iterates over a collection of style images to display a variety of output images, formatted as a table and as an animation.</li><li><strong>HiDef </strong>— These scripts include special logic for processing high resolution images. This is generally done by breaking the calculation down at some level to process using image tiles.</li></ol><h3>Script Output Examples</h3><p>For illustration, here are some prior runs of each script. Keep in mind these are works in progress. Feel free to submit your results and improvements!</p><p><strong>Deep Dream</strong></p><ol><li><strong>Simple: </strong><a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422151353/com.simiacryptus.mindseye.deep_dream.Simple.zip">Zip</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422151353/com.simiacryptus.mindseye.deep_dream.Simple.pdf">Pdf</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422151353/com.simiacryptus.mindseye.deep_dream.Simple.html">html</a></li><li><strong>High Resolution: </strong><a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422160548/com.simiacryptus.mindseye.deep_dream.HiDef.zip">Zip</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422160548/com.simiacryptus.mindseye.deep_dream.HiDef.pdf">Pdf</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422160548/com.simiacryptus.mindseye.deep_dream.HiDef.html">html</a></li></ol><p><strong>Style Transfer</strong></p><ol><li><strong>Simple: </strong><a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422153036/com.simiacryptus.mindseye.style_transfer.Simple.zip">Zip</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422153036/com.simiacryptus.mindseye.style_transfer.Simple.pdf">pdf</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422153036/com.simiacryptus.mindseye.style_transfer.Simple.html">html</a></li><li><strong>Enlarging: </strong><a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422162714/com.simiacryptus.mindseye.style_transfer.Enlarging.zip">Zip</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422162714/com.simiacryptus.mindseye.style_transfer.Enlarging.pdf">pdf</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422162714/com.simiacryptus.mindseye.style_transfer.Enlarging.html">html</a></li><li><strong>Style Survey: </strong><a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422184037/com.simiacryptus.mindseye.style_transfer.StyleSurvey.zip">Zip</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422184037/com.simiacryptus.mindseye.style_transfer.StyleSurvey.pdf">pdf</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422184037/com.simiacryptus.mindseye.style_transfer.StyleSurvey.html">html</a></li><li><strong>Parameter Sweep: </strong><a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422171118/com.simiacryptus.mindseye.style_transfer.ParameterSweep.zip">Zip</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422171118/com.simiacryptus.mindseye.style_transfer.ParameterSweep.pdf">Pdf</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422171118/com.simiacryptus.mindseye.style_transfer.ParameterSweep.html">html</a></li><li><strong>High Resolution: </strong><a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422211857/com.simiacryptus.mindseye.style_transfer.HiDef.zip">Zip</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422211857/com.simiacryptus.mindseye.style_transfer.HiDef.pdf">Pdf</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422211857/com.simiacryptus.mindseye.style_transfer.HiDef.html">html</a></li></ol><p><strong>Texture Generation</strong></p><ol><li><strong>Simple: </strong><a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422154353/com.simiacryptus.mindseye.texture_generation.Simple.zip">Zip</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422154353/com.simiacryptus.mindseye.texture_generation.Simple.pdf">pdf</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422154353/com.simiacryptus.mindseye.texture_generation.Simple.html">html</a></li><li><strong>Enlarging: </strong><a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422074606/com.simiacryptus.mindseye.texture_generation.Enlarging.zip">Zip</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422074606/com.simiacryptus.mindseye.texture_generation.Enlarging.pdf">Pdf</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422074606/com.simiacryptus.mindseye.texture_generation.Enlarging.html">html</a></li><li><strong>Style Survey: </strong><a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422083245/com.simiacryptus.mindseye.texture_generation.StyleSurvey.zip">Zip</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422083245/com.simiacryptus.mindseye.texture_generation.StyleSurvey.pdf">Pdf</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422083245/com.simiacryptus.mindseye.texture_generation.StyleSurvey.html">html</a></li><li><strong>Parameter Sweep: </strong><a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422081155/com.simiacryptus.mindseye.texture_generation.ParameterSweep.zip">Zip</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422081155/com.simiacryptus.mindseye.texture_generation.ParameterSweep.pdf">Pdf</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422081155/com.simiacryptus.mindseye.texture_generation.ParameterSweep.html">html</a></li><li><strong>High Resolution: </strong><a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422102456/com.simiacryptus.mindseye.texture_generation.HiDef.zip">Zip</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422102456/com.simiacryptus.mindseye.texture_generation.HiDef.pdf">Pdf</a> — <a href="https://mindseye-art-7f168.s3.us-west-2.amazonaws.com/reports/20180422102456/com.simiacryptus.mindseye.texture_generation.HiDef.html">html</a></li></ol><h3>Further Reading</h3><ol><li><a href="https://github.com/SimiaCryptus/MindsEye">Simia Cryptus MindsEye</a> — The parent project, focusing on Java 8 Neural Networks</li><li><a href="http://arxiv.org/abs/1508.06576">Original Style Transfer Paper</a></li><li><a href="https://research.googleblog.com/2015/06/inceptionism-going-deeper-into-neural.html">Original Google Deep Dream Blog Post</a></li><li><a href="https://developer.nvidia.com/cudnn">CuDNN</a> powers most of the heavy compute</li><li><a href="http://aparapi.com/">Aparapi</a> is another supported tool for GPU accelerated layers</li><li><a href="http://artsandculture.google.com/category/art-movement">Google Arts &amp; Culture</a> — Excellent resource for inspiration</li></ol><p>Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=170337ba41be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recursive Subspace and Quadratic Quasi-Newton Optimization]]></title>
            <link>https://acharneski.medium.com/originally-posted-as-http-blog-simiacryptus-com-2017-12-optimization-research-html-cc7ee8623ab1?source=rss-b5d0d73f6aa4------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc7ee8623ab1</guid>
            <category><![CDATA[research]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[Andrew Charneski]]></dc:creator>
            <pubDate>Sat, 23 Dec 2017 18:09:02 GMT</pubDate>
            <atom:updated>2017-12-23T21:22:23.507Z</atom:updated>
            <content:encoded><![CDATA[<p>Originally Posted as <a href="http://blog.simiacryptus.com/2017/12/optimization-research.html">http://blog.simiacryptus.com/2017/12/optimization-research.html</a></p><p>Now that I’ve cleaned up the testing and documentation of MindsEye, I have been able to re-focus on why I started writing it: Optimization Algorithm Research. In the course of playing with this code I have tried countless ideas, most of which taught me though failure instead of success… However I do have two ideas, fully implemented and demonstrated in MindsEye, that I’d like to introduce today: <a href="https://github.com/SimiaCryptus/MindsEye/blob/8f4abfed33aa88751a35ad3a163e34314390e5bd/src/main/java/com/simiacryptus/mindseye/opt/orient/RecursiveSubspace.java">Recursive Subspace Optimization</a> allows deep networks to be trained effectively, and <a href="https://github.com/SimiaCryptus/MindsEye/blob/8f4abfed33aa88751a35ad3a163e34314390e5bd/src/main/java/com/simiacryptus/mindseye/opt/orient/QQN.java">Quadratic Quasi-Newton</a> enhances L-BFGS with a quadratic term on the line-search path.</p><p><strong>Recursive Subspace Optimization</strong></p><p>One common problem in network training is an “imbalanced network”. This easily happens in deep architectures when one layer has somewhat small weights, and the next layer has comparatively large weights, or visa versa. This causes the learning gradient to have a much higher magnitude in certain layers than in others, making convergence difficult since some layers have difficulty learning. Such a network could theoretically be re-balanced by re-scaling each layer; for example, the weights in one layer could be halved, and the weights in the next layer doubled, and the net effect cancels out. The network behaves the same, but has different gradients and may learn faster.</p><p>In most state-of-the-art networks, the balancing problem is solved by normalization meta-layers, which rescales each inter-layer signal so it has unit energy. By rescaling into a predetermined result, two effects are gained. Gradient magnitudes per-layer will be normalized, and back-propagation will no longer simply try to amplify signal magnitudes. (By “signal” I mean the multidimensional data output by a layer)</p><p>However, what if we chose different rates for each layer in such a way as to re-balance the learning, without needing to modify the network? Learning should then work fine, but we still have the problem of choosing these weights…</p><p>Inside a single gradient descent optimization iteration, we compute a very-high-dimensional gradient, one dimension for each weight. Normally, we would take this gradient and perform steepest descent with some rate parameter and/or line search strategy. However, in recognizing this layer-balancing issue, we could rescale this gradient by a per-layer factor to determine the next iteration’s point. If we have N layers, we now have a choice of N parameters to take the next step (via re-weighting). We of course want to pick the optimal vector, so why not define this as a gradient descent optimization problem as well?</p><p>This turned out to be fairly easy to <a href="https://github.com/SimiaCryptus/MindsEye/blob/8f4abfed33aa88751a35ad3a163e34314390e5bd/src/main/java/com/simiacryptus/mindseye/opt/orient/RecursiveSubspace.java">implement in MindsEye</a>, and it seems to work quite well. The multiple iterations spent inside the inner optimization mostly replace the line search iterations which would have taken place, and by decoupling the per-layer learning rates it can easily handle gradients many orders of magnitude dissimilar.</p><p>A similar method was <a href="http://www.eurasip.org/Proceedings/Eusipco/Eusipco2017/papers/1570347632.pdf">published this year in Europe</a>, but their version uses an explicitly computed Hessian, a spherical trust region, and a rigid 2-phase structure. The method I implemented shares the per-layer-rate, multi-phase-subspace optimization idea, but uses the same kind of optimization model in both phases, both of which are first-order. Theoretically, the method I propose could recurse into three or more phases, although I can’t think of a use for that right now…</p><p><strong>Quadratic Quasi-Newton Optimization</strong></p><p>Another feature I want to introduce today is something I am calling Quadratic Quasi-Newton optimization. This method seeks a hybrid solution with the strengths of both Stochastic Gradient Descent and Quasi-Newton (e.g. L-BFGS) approaches by defining a quadratic path for the line search phase.</p><p>Stochastic Gradient Descent (with momentum and regularization) is arguably the most common strategy used today in training deep models against big data. This method exploits only the direct differential information made available by a single evaluation over a partial sample of the data — an approximate vector of steepest descent. This leaves the choice of rate, a.k.a. step size, unspecified. In contrast, Quasi-Newton strategies predict a full optimum-point prediction on each iteration; not just a vector but also the distance. Each update uses an estimate of the second derivatives to form a quadratic functional neighborhood, which prescribes a single point at the minimum (including distance.)</p><p>While quasi-newton strategies may seem “smarter” and therefore “better”, in practice they suffer from some significant problems:</p><ol><li>2nd-order derivative estimates are very sensitive to the assumption that the function is smooth and deterministic — any re-sampling of the data will invalidate the history of the known gradient rays, and numeric resolution issues can interfere with training.</li><li>In regions of high nonlinearity, which is fairly common, the strategy may suggest a step resulting in a fitness decrease. This is why the L-BFGS strategy prescribes the Armijo &amp;amp; Wolfe line search conditions to guarantee convergence — in the event of a “bad” step, just try a smaller step. As long as the vector is in the direction of gradient descent vector, we are guaranteed to find an “ok” step even if it is very small.</li><li>The estimation of the inverse hessian is a nontrivial operation. Various strategies balance memory, CPU, and accuracy, but the cost can still be significant. This also adds complexity and additional metaparameters.</li><li>At a sufficiently small step size, not only are the extra compute resources going to waste, but we pretty much know that the direction we are choosing is not optimal because it is at an angle with the known steepest descent vector.</li></ol><p>In either case, the method predicts what direction the solution lies in, and in either case the step size is held variable subject to some conditions to guarantee at least eventual convergence to a local optimum. Effectively, this means we can break down the optimization problem into two components that operate each iteration: The first component evaluates the differential module at the start of each iteration and produces a path through parameter space, leaving us with a one-dimensional function (with a known derivative) for us to optimize. The second uses this path to find the next iteration’s location in parameter space via an iterative “line search” procedure.</p><p>Our suggested improvement, implemented in a <a href="https://github.com/SimiaCryptus/MindsEye/blob/8f4abfed33aa88751a35ad3a163e34314390e5bd/src/main/java/com/simiacryptus/mindseye/opt/orient/QQN.java">simple module in MindsEye</a>, is to use a quadratic curve as the path used in the line search stage of the optimization process. This quadratic curve would be defined by intersecting the current position and gradient and the QN-predicted optimal point; the path would align with the steepest descent vector at the current point and curve smoothly through the predicted minimum. This parametric model is then fed to our line search procedure, which solves for an accepted step size. At a very small step size, this method agrees with gradient descent, but smoothly changes to account for second-order curvature effects so that a step size of 1 is exactly the QN-predicted optimum.</p><p><strong>Results</strong></p><p><a href="https://github.com/SimiaCryptus/MindsEye/blob/8f4abfed33aa88751a35ad3a163e34314390e5bd/src/test/java/com/simiacryptus/mindseye/labs/matrix/OptimizerComparison.java#L212">We tested these methods</a> by training a 3-layer convolutional network against the MNIST dataset. This problem is simple enough to run quickly, and complex enough to present a learning challenge. We used two network variants; one variant has normalization layers and the other does not, and both are initialized with a constant weight magnitude. The optimization setups tested are:</p><ol><li>L-BFGS with normalized network</li><li>L-BFGS with non-normalized network</li><li>Modified L-BFGS, with normalized network, using strong line search</li><li>Recursive Subspace with non-normalized network, using L-BFGS as the inner optimizer.</li><li>Quadratic Quasi-Newton with normalized network</li><li>Recursive Subspace with non-normalized network, using QQN as the inner optimizer.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*FqsqtbmpKsK2AJvf.png" /></figure><p>Initial results show significant benefits over standard L-BFGS, though much of the difference seen is accounted for by simply adding a strong line search to the standard L-BFGS algorithm. Over time as the test suite is expanded I should have much better data across many problems and variants to compare. Stay tuned for more!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc7ee8623ab1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Test Driven Development for Neural Networks, Part II — AB Testing]]></title>
            <link>https://acharneski.medium.com/test-driven-development-for-neural-networks-part-ii-ab-testing-b76cc0be9182?source=rss-b5d0d73f6aa4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b76cc0be9182</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[test-driven-development]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Andrew Charneski]]></dc:creator>
            <pubDate>Fri, 15 Dec 2017 02:19:25 GMT</pubDate>
            <atom:updated>2017-12-23T21:30:47.562Z</atom:updated>
            <content:encoded><![CDATA[<h3>Test Driven Development for Neural Networks, Part II — AB Testing</h3><p>Originally published at <a href="http://blog.simiacryptus.com/2017/12/test-driven-development-for-neural-nets.html">http://blog.simiacryptus.com/2017/12/test-driven-development-for-neural-nets.html</a></p><p>In the last article, we covered a common testing framework for individual components, but we didn’t cover how these networks are actually trained. More specifically, how should we design a test suite to cover something so broad as optimization? A big problem here is that the components are heavily dependent on each other and also vary greatly in function and contract, and so there are few opportunities for generic testing and validation logic. One simple way to test these on functional level is to use them on demonstration problems, perhaps with the notebook format we used for our component unit tests. This prevents us from isolating every component, and opens up a myriad of possible ways we could configure tests, but it’s a start.</p><p>The basic version of this method is to establish a baseline demonstration notebook. In MindsEye I have used the <a href="https://github.com/SimiaCryptus/MindsEye/blob/3053e759f8cf0921157fe24df80f4a1e90069c00/src/test/java/com/simiacryptus/mindseye/opt/MnistTestBase.java">MNIST handwritten digit classification problem</a> to be the baseline; it’s pretty much the <a href="https://github.com/SimiaCryptus/MindsEye/blob/3053e759f8cf0921157fe24df80f4a1e90069c00/reports/com/simiacryptus/mindseye/opt/trainable/SimpleStochasticGradientDescentTest/test.md">“Hello World” of AI</a>. We start with this problem being solved in the most basic way using the most basic network and the simplest functional optimization setup. For each component, we derive a test from this template and override appropriate methods to plug in our component; this provides the flexibility to demonstrate the component’s properties, such as sparsity.</p><p>Inheritance alone, though flexible, provides limited ability to capture the complex combinatoric nature of optimization setups. To improve this and allow better coverage of the possibilities, I’ve designed a framework to assist with this combinatoric test problem. This framework allows you to establish various interchangeable strategies, so that once setup they can combine interchangeably to produce new tests. For an executable test, you must simply select one strategy each of the following types:</p><p><strong>Network</strong> — How is it setup? Examples:</p><ol><li><a href="https://github.com/SimiaCryptus/MindsEye/blob/3053e759f8cf0921157fe24df80f4a1e90069c00/src/test/java/com/simiacryptus/mindseye/labs/matrix/MnistTests.java#L46">Simple single-layer linear</a></li><li><a href="https://github.com/SimiaCryptus/MindsEye/blob/3053e759f8cf0921157fe24df80f4a1e90069c00/src/test/java/com/simiacryptus/mindseye/labs/matrix/MnistTests.java#L60">Simple convolutional network</a></li><li>Deep convolutional network</li></ol><p><strong>Optimization Configuration</strong> — involves the choice of several sub-strategies and meta-parameters. Examples:</p><ol><li><a href="https://github.com/SimiaCryptus/MindsEye/blob/3053e759f8cf0921157fe24df80f4a1e90069c00/src/test/java/com/simiacryptus/mindseye/labs/matrix/TextbookOptimizers.java#L56">Stochastic Gradient Descent</a></li><li><a href="https://github.com/SimiaCryptus/MindsEye/blob/3053e759f8cf0921157fe24df80f4a1e90069c00/src/test/java/com/simiacryptus/mindseye/labs/matrix/TextbookOptimizers.java#L72">Conjugate Gradient Descent</a></li><li><a href="https://github.com/SimiaCryptus/MindsEye/blob/3053e759f8cf0921157fe24df80f4a1e90069c00/src/test/java/com/simiacryptus/mindseye/labs/matrix/TextbookOptimizers.java#L87">L-BFGS</a></li><li><a href="https://github.com/SimiaCryptus/MindsEye/blob/3053e759f8cf0921157fe24df80f4a1e90069c00/src/test/java/com/simiacryptus/mindseye/labs/matrix/TextbookOptimizers.java#L103">OWL-QN</a></li></ol><p><strong>Data</strong> — What data set are we studying?</p><ol><li><a href="https://github.com/SimiaCryptus/MindsEye/blob/3053e759f8cf0921157fe24df80f4a1e90069c00/src/test/java/com/simiacryptus/mindseye/labs/matrix/MnistTests.java">MNIST</a> — A small gray scale image tile classification data set which is easy to achieve ~91% on. Gray scale 28x28 images for each 0–9 digit.</li><li><a href="https://github.com/SimiaCryptus/MindsEye/blob/3053e759f8cf0921157fe24df80f4a1e90069c00/src/test/java/com/simiacryptus/mindseye/labs/matrix/CifarTests.java">CIFAR</a> — Another, much more difficult small image tile classification data set. Color 32x32 images in 10 categories.</li></ol><p><strong>Method</strong> — This defines various ways that a network is used. Examples:</p><ol><li><a href="https://github.com/SimiaCryptus/MindsEye/blob/3053e759f8cf0921157fe24df80f4a1e90069c00/src/main/java/com/simiacryptus/mindseye/test/ClassifyProblem.java">Classification</a> — Learn to classify the images</li><li><a href="https://github.com/SimiaCryptus/MindsEye/blob/3053e759f8cf0921157fe24df80f4a1e90069c00/src/main/java/com/simiacryptus/mindseye/test/EncodingProblem.java">Representation</a> — Derive a common decoding network and input values which reconstruct the data set</li><li>Denoising Autoencoder (in development)</li><li>Generative Adversarial Networks (in development)</li></ol><p>Just in the 12 example strategies listed above, we could easily define 72 separate tests. Adding a single new strategy will increase that number by 18–36 possible tests; the point being the effort required to create new tests is so low that the main effort is now judiciously choosing which ones to actually execute. The standard reports published with MindsEye can be found in the <a href="https://github.com/SimiaCryptus/MindsEye/tree/3053e759f8cf0921157fe24df80f4a1e90069c00/reports/com/simiacryptus/mindseye">reports directory</a>, mostly in <a href="https://github.com/SimiaCryptus/MindsEye/tree/3053e759f8cf0921157fe24df80f4a1e90069c00/reports/com/simiacryptus/mindseye/labs/matrix">labs/matrix</a>.</p><p>So now we can run all our code with test cases, in a variety of setups, each producing a detailed report, with minimal effort. In addition to testing, documentation, and demonstration, this is an ideal platform to support an AB testing process. By looking at the results for a variety of problems solved identically except for one given change, we can determine how effective various options are in various situations. For example, this <a href="https://github.com/SimiaCryptus/MindsEye/blob/3053e759f8cf0921157fe24df80f4a1e90069c00/reports/com/simiacryptus/mindseye/labs/matrix/OptimizerComparison/CompareTextbook/classification.md">test report</a> compares various optimization methods on a particular problem, resulting in the following graph:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*TAkGbjXnW1hOUIKs." /></figure><p>This completes our review of the testing strategy for MindsEye. Using this highly-leveraged framework, we can ensure that every component, and any new ones, are well tested with accurate documentation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b76cc0be9182" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Test Driven Development for Neural Networks, Part I — Unit Testing]]></title>
            <link>https://acharneski.medium.com/test-driven-development-for-neural-networks-part-i-unit-testing-9cce327d321?source=rss-b5d0d73f6aa4------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cce327d321</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[test-driven-development]]></category>
            <dc:creator><![CDATA[Andrew Charneski]]></dc:creator>
            <pubDate>Fri, 15 Dec 2017 02:15:06 GMT</pubDate>
            <atom:updated>2017-12-23T21:32:15.260Z</atom:updated>
            <content:encoded><![CDATA[<h3>Test Driven Development for Neural Networks, Part I — Unit Testing</h3><p>Originally posted on <a href="http://blog.simiacryptus.com/2017/12/unit-testing-and-neural-networks.html">http://blog.simiacryptus.com/2017/12/unit-testing-and-neural-networks.html</a></p><p>A critical part of any good software is test code. It is an understatement that tests improve quality; they improve the scalability of the entire software development process. Tests let you write more code, faster code, better code. One of the leading testing methodologies is unit testing: the philosophy of breaking down software into individual components and testing each separately. It turns out that a great case study in unit test design also happens to be one of today’s hot tech topics — artificial neural networks.</p><p>Known by a plethora of names and acronyms, neural networks are a modular data processing structure whose form is inspired by biological neural networks. A core learning algorithm/property used is back-propagation; it enables the iterative improvement (known as Gradient Descent) of the myriad of free variables within an arbitrarily complex network to improve a scalar “fitness” output — a process also known as machine learning.</p><p>Therefore, key components in developing neural software include:</p><ul><li>A <a href="https://github.com/SimiaCryptus/MindsEye/tree/master/src/main/java/com/simiacryptus/mindseye/layers">library</a> of components</li><li>A <a href="https://github.com/SimiaCryptus/MindsEye/tree/master/src/main/java/com/simiacryptus/mindseye/network">way</a> to wire them together</li><li>A <a href="https://github.com/SimiaCryptus/MindsEye/tree/master/src/main/java/com/simiacryptus/mindseye/opt">way</a> to train them</li></ul><p>Today, we’ll be talking about #1.</p><p><strong>Testing Requirements</strong></p><p>Back-propagation uses the chain rule to ensure <a href="https://en.wikipedia.org/wiki/Composability">composability</a>, which allows the construction of arbitrarily complex networks. This means each component must provide executable implementations of both a multivariate function and its derivative. Although in practice this function should be fairly smooth, in principle the function is arbitrary and can even have kinks. The big requirement, however, is that the derivative agrees with the functional. We’ll call this “<em>numerical consistency</em>”.</p><p>It turns out that this component library can grow fairly large. Just in my personal research, I have 70 layers in the current version of MindsEye. With a library that large, I have not only found it challenging to maintain quality, I have even had a hard time remembering what a layer is supposed to be doing! I try to make the names self-explanatory, but it is clear that we need <em>documentation </em>in addition to quality assurance.</p><p>There are good reasons that, at the time of this writing, the Universal AI hasn’t taken over the world. One big reason is it isn’t fast enough yet — speed has therefore often determined the rate of development. It follows that we are interested in <em>performance benchmarks</em>, and these should be tested and documented.</p><p>In order to gain faster performance, especially in the field of GPU-accelerated components, we may use a lower precision such as 32 or even 16 bit floats, or there may be other minor details in how the function is implemented. Usually this will behave fine, but we certainly want to keep an eye on it. When we verify the behavior of this function, we therefore expect some amount of small but acceptable error from what we’d consider the analytically ideal value. This error can be significant in certain cases, and we’d like to document this <em>numerical accuracy</em>.</p><p>Another important and often overlooked requirement for a neural network is the ability to save and load it from memory, and communicate it with others. Our documentation should include the <em>serialization format</em>, and the tests should ensure valid serialization.</p><p><strong>Implementation</strong></p><p>So in summary, we want to do the following for each component:</p><ol><li>Documentation</li><li>Document what it does</li><li>Document the serialization format</li><li>Testing that the function “behaves”</li><li>Ensure it is a numerically consistent function</li><li>Ensure it is an accurate function</li><li>Quantitative benchmarks for incremental improvement</li><li>Benchmark the performance</li><li>Benchmark the accuracy</li></ol><p>There is a great software pattern that can be used to address the testing and documentation requirements with the same shared code: A notebook. Basically, the idea is for a single-threaded script to output a report that interleaves code with the results of that code’s evaluation. The result is a document produced by a test case, containing a demonstration of most up-to-date implementation of the given component. It can, for example, simply evaluate network.toJson() and document the serialization format. In MindsEye we use a custom notebook library to generate reports in GitHub Markdown.</p><p>We would like to design a notebook which tests and demonstrates all key aspects of our component. In order to do that, it is not enough to specify the component — it has to be a specific configuration of the component, with supplied inputs. Therefore our <a href="https://github.com/SimiaCryptus/MindsEye/blob/master/src/test/java/com/simiacryptus/mindseye/layers/LayerTestBase.java">base class</a> requires only these two definitions, and further testing is defined by additional report configurations.</p><p>So how do we demonstrate what a component does? One obvious response is to simply print out some example inputs and outputs — this is the default of our report. If the component is itself a network of sub-components, we could visualize the network using a <a href="https://github.com/SimiaCryptus/MindsEye/blob/f88306790ff34d6c6d04863793e6351f94151a28/reports/com/simiacryptus/mindseye/layers/cudnn/f64/ConvolutionNetworkTest/test.md">graph visualization</a>. If the component is a simple uni-variate <a href="https://github.com/SimiaCryptus/MindsEye/blob/f88306790ff34d6c6d04863793e6351f94151a28/reports/com/simiacryptus/mindseye/layers/java/GaussianActivationLayerTest/test.md">activation function</a>, a plot would be nice. Another way to demonstrate what a component does is by comparison; demonstrate that it does the same thing as another component (i.e. a <a href="https://github.com/SimiaCryptus/MindsEye/blob/f88306790ff34d6c6d04863793e6351f94151a28/reports/com/simiacryptus/mindseye/layers/cudnn/f64/ConvolutionLayerTest/test.md">reference implementation</a>.) This is especially useful in performance-critical components which may have several implementations, such as the convolution layer.</p><p>Now that we’ve characterized the layer, we need to test that the function “behaves well”. For the most part, our key tool for this is to numerically estimate derivatives using <a href="http://mathworld.wolfram.com/FiniteDifference.html">finite difference</a> methods and to compare them with the implemented derivatives. One difficulty of this is that the numerical accuracy effects the ability to evaluate small deviations, another is this estimation is sensitive to function smoothness. However, in most cases it clearly and easily differentiates between a broken and functional implementation. I have developed a fairly thorough <a href="https://github.com/SimiaCryptus/MindsEye/blob/f88306790ff34d6c6d04863793e6351f94151a28/src/test/java/com/simiacryptus/mindseye/layers/DerivativeTester.java">tool</a> for this.</p><p>Another detail that is important to check for, at least in how MindsEye is implemented, is batch invariance. Via programming optimizations, network evaluations are faster when conducted in batch. In training, the network will not generally execute one row of data at a time; it is handled in chunks of some digestible-yet-large batch size. With few exceptions, the components should behave the same whether or not the execution was batched or one-at-a-time.</p><p>Finally, we need quantitative figures that indicate a spectrum of continuous improvement to be reflected in our reports. The obvious is performance figures that we’d like to see go to zero or infinity; to gather good performance metrics we simply time how long N executions takes. Another figure, which often describes the performance trade-off penalty, is numerical accuracy.</p><p><strong>Conclusion</strong></p><p>In a nutshell, that is how I have ensured quality and scalable development in MindsEye. Due to well defined and testable functionality contracts, a huge library of components can be supported by shared test code requiring only minimal per-component implementation. This is one of the hidden requirements of test code — it is generic enough to 1) be super easy to use, and 2) not go stale.</p><p>Thanks for reading, and have an awesome day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cce327d321" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>