<?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 Jerry Liu on Medium]]></title>
        <description><![CDATA[Stories by Jerry Liu on Medium]]></description>
        <link>https://medium.com/@twairball?source=rss-593f1c407761------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ipdxRBF0yUEtmalDX62UUw.jpeg</url>
            <title>Stories by Jerry Liu on Medium</title>
            <link>https://medium.com/@twairball?source=rss-593f1c407761------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 06:19:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@twairball/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[Chromatic Privacy Policy]]></title>
            <link>https://medium.com/@twairball/chromatic-privacy-policy-631690e3676e?source=rss-593f1c407761------2</link>
            <guid isPermaLink="false">https://medium.com/p/631690e3676e</guid>
            <dc:creator><![CDATA[Jerry Liu]]></dc:creator>
            <pubDate>Wed, 01 May 2019 06:05:41 GMT</pubDate>
            <atom:updated>2019-05-01T06:05:41.631Z</atom:updated>
            <content:encoded><![CDATA[<h3>Privacy Policy</h3><p>Jerry Liu built the Chromatic app as a Commercial app. This SERVICE is provided by Jerry Liu and is intended for use as is.</p><p>This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service.</p><p>If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy.</p><p>The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at Chromatic unless otherwise defined in this Privacy Policy.</p><p><strong>Information Collection and Use</strong></p><p>For a better experience, while using our Service, I may require you to provide us with certain personally identifiable information. The information that I request will be retained on your device and is not collected by me in any way.</p><p><strong>Log Data</strong></p><p>I want to inform you that whenever you use my Service, in a case of an error in the app I collect data and information (through third party products) on your phone called Log Data. This Log Data may include information such as your device Internet Protocol (“IP”) address, device name, operating system version, the configuration of the app when utilizing my Service, the time and date of your use of the Service, and other statistics.</p><p><strong>Cookies</strong></p><p>Cookies are files with a small amount of data that are commonly used as anonymous unique identifiers. These are sent to your browser from the websites that you visit and are stored on your device’s internal memory.</p><p>This Service does not use these “cookies” explicitly. However, the app may use third party code and libraries that use “cookies” to collect information and improve their services. You have the option to either accept or refuse these cookies and know when a cookie is being sent to your device. If you choose to refuse our cookies, you may not be able to use some portions of this Service.</p><p><strong>Service Providers</strong></p><p>I may employ third-party companies and individuals due to the following reasons:</p><ul><li>To facilitate our Service;</li><li>To provide the Service on our behalf;</li><li>To perform Service-related services; or</li><li>To assist us in analyzing how our Service is used.</li></ul><p>I want to inform users of this Service that these third parties have access to your Personal Information. The reason is to perform the tasks assigned to them on our behalf. However, they are obligated not to disclose or use the information for any other purpose.</p><p><strong>Security</strong></p><p>I value your trust in providing us your Personal Information, thus we are striving to use commercially acceptable means of protecting it. But remember that no method of transmission over the internet, or method of electronic storage is 100% secure and reliable, and I cannot guarantee its absolute security.</p><p><strong>Links to Other Sites</strong></p><p>This Service may contain links to other sites. If you click on a third-party link, you will be directed to that site. Note that these external sites are not operated by me. Therefore, I strongly advise you to review the Privacy Policy of these websites. I have no control over and assume no responsibility for the content, privacy policies, or practices of any third-party sites or services.</p><p><strong>Children’s Privacy</strong></p><p>These Services do not address anyone under the age of 13. I do not knowingly collect personally identifiable information from children under 13. In the case I discover that a child under 13 has provided me with personal information, I immediately delete this from our servers. If you are a parent or guardian and you are aware that your child has provided us with personal information, please contact me so that I will be able to do necessary actions.</p><p><strong>Changes to This Privacy Policy</strong></p><p>I may update our Privacy Policy from time to time. Thus, you are advised to review this page periodically for any changes. I will notify you of any changes by posting the new Privacy Policy on this page. These changes are effective immediately after they are posted on this page.</p><p><strong>Contact Us</strong></p><p>If you have any questions or suggestions about my Privacy Policy, do not hesitate to contact me at jerry@lioniq.com.</p><p>This privacy policy page was created at <a href="https://privacypolicytemplate.net/">privacypolicytemplate.net</a> and modified/generated by <a href="https://app-privacy-policy-generator.firebaseapp.com/">App Privacy Policy Generator</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=631690e3676e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Eigen with iOS Swift]]></title>
            <link>https://medium.com/lioniq/eigen-with-ios-swift-ec7ce697f17c?source=rss-593f1c407761------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec7ce697f17c</guid>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[numpy]]></category>
            <dc:creator><![CDATA[Jerry Liu]]></dc:creator>
            <pubDate>Wed, 01 May 2019 02:58:09 GMT</pubDate>
            <atom:updated>2019-05-01T03:03:59.620Z</atom:updated>
            <content:encoded><![CDATA[<p>How to add Eigen to your iOS Swift project.</p><p>You’ve gotten OpenCV working inside your app, but still need a Numpy/Scipy alternative for iOS. Since OpenCV is now in C++, we need a C++ linear algebra library that can interop with cv::Mat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/128/1*I9RcWQMhXL1bjVi9xGz4bQ.png" /></figure><p><a href="http://eigen.tuxfamily.org/">Eigen</a> is a C++ library for linear algebra with stable tested codebase and deployed extensively in many applications, including Tensorflow. There are other great choices such as <a href="http://dlib.net/">dlib</a> and <a href="http://arma.sourceforge.net/">Armadillo</a>, but eigen being a header-only library makes compatibility and compiling with Xcode and Swift much easier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/126/1*NdqHOzZuyJXhqfveKhhJnw.png" /><figcaption>Eigen is a C++ library for linear algebra</figcaption></figure><h4>Setup Eigen</h4><ol><li><a href="http://bitbucket.org/eigen/eigen/get/3.3.7.tar.bz2">Download Eigen</a> from <a href="http://eigen.tuxfamily.org/">official site</a> and extract to your project directory. It helps to rename the directory with current version, e.g. my_ios_app/eigen_3.3.7.</li><li>In Xcode, goto Build Settings then Header Search Paths and add the above eigen directory, e.g. $(PROJECT_DIR)/eigen_3.3.7</li></ol><h4>Create Wrapper Class</h4><p>To test that Eigen is added correctly, we’ll create a wrapper class to report the library version.</p><p>Goto File -&gt; New -&gt; File and select Cocoa Touch Class. We’ll name it EigenWrapper.</p><p>Xcode will show a popup, click “Create Bridging Header”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wIULOqB69nb69sRJBqnepQ.png" /><figcaption>Hit “Create Bridging Header”</figcaption></figure><p>This will create 2 files, EigenWrapper.h and EigenWrapper.m in our project. To use C++ in Xcode, rename EigenWrapper.m to EigenWrapper.mm.</p><p>Add a static method to EigenWrapper.h:</p><pre><strong>@interface</strong> EigenWrapper : NSObject</pre><pre>+ (NSString *)eigenVersionString;</pre><pre><strong>@end</strong></pre><p>Then in EigenWrapper.mm we’ll import the header file and the Eigen library:</p><pre>#import &lt;Eigen/Core&gt;</pre><pre>#import &quot;EigenWrapper.h&quot;</pre><p>The library version is available at build time as macros, and we can return this to Objc with NSString:</p><pre>+ (NSString *)eigenVersionString {</pre><pre><strong>    return</strong> [NSString stringWithFormat:@&quot;Eigen Version %d.%d.%d&quot;,     EIGEN_WORLD_VERSION, EIGEN_MAJOR_VERSION, EIGEN_MINOR_VERSION];</pre><pre>}</pre><h4>Setup Bridging Header</h4><p>XCode uses a Bridging Header file to connect Obj-C (and in our case, Obj-C++) to Swift. The Bridging Header file will be named my_ios_app-Bridging-Header.h. To allow our swift code to access our new wrapper class, we’ll need to import it within this Bridging Header:</p><pre>#import &quot;EigenWrapper.h&quot;</pre><h4>Compile and Test</h4><p>To make sure its working, lets call this in AppDelegate.swift</p><pre><strong>func</strong> application(<strong>_</strong> application: UIApplication,   didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: <strong>Any</strong>]?) -&gt; Bool {</pre><pre>    print(&quot;eigen: &quot;, EigenWrapper.eigenVersionString())</pre><pre><strong>    return</strong> <strong>true</strong></pre><pre>}</pre><p>Hit Cmd+R and watch the console log. If everything is setup correctly, we’ll see the library version reported:</p><pre><strong>eigen:  Eigen Version 3.3.7</strong></pre><p>Happy coding!</p><h4>Tips</h4><ul><li>You don’t have to include the eigen library directly in the iOS app project, (it adds 16MB for library size). But it makes the repo easier to share and distribute among team members. It is crucial to setup the Header Search Path so that Xcode knows where to find it.</li><li>Include the eigen headers directly e.g. &lt;Eigen/Core&gt;, not from &lt;Eigen/src/Core&gt;.</li></ul><p>—</p><h4><strong>References:</strong></h4><ul><li><a href="https://stackoverflow.com/questions/35658420/installing-eigen-on-mac-os-x-for-xcode">Installing Eigen on Mac OS X for XCode</a></li><li><a href="https://stackoverflow.com/questions/21497064/how-to-check-the-version-number-of-eigen-c-template-library">How to check the version number of Eigen C++ template library?</a></li><li><a href="https://medium.com/@yiweini/opencv-with-swift-step-by-step-c3cc1d1ee5f1">OpenCV with Swift - step by step</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec7ce697f17c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lioniq/eigen-with-ios-swift-ec7ce697f17c">Eigen with iOS Swift</a> was originally published in <a href="https://medium.com/lioniq">Lion IQ</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Face Detection and Tracking for Real-Time apps]]></title>
            <link>https://medium.com/lioniq/face-detection-and-tracking-for-real-time-apps-7bb0de7dd512?source=rss-593f1c407761------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bb0de7dd512</guid>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[object-detection]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Jerry Liu]]></dc:creator>
            <pubDate>Wed, 08 Aug 2018 07:47:10 GMT</pubDate>
            <atom:updated>2018-08-08T07:47:10.965Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*vMiMMU6sIfb7aUFXerUIWw.png" /></figure><p>Modern object and face detection methods use computationally expensive deep learning models to perform detection within an image. There is no free lunch however — faster detectors are generally sacrifice precision for performance.</p><p>While the performance of detectors such as YOLO allows it to be applied in real-time, this comes at a cost:</p><ul><li>Computational expense — we are all slaves to GPU.</li><li>Sacrifice precision for speed.</li><li>Bounding boxes returned by detectors will “bounce” a lot even if the subject is not moving</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*RFpjH8D6TStBaYuZYehe_g.png" /><figcaption>There is no free lunch — fast detectors attain lower precision</figcaption></figure><p>For image processing we can get around this by spinning up multiple servers and process large image batches in parallel, essentially trading money for speed. For real-time or video applications however, we’ll need a different approach.</p><p><a href="https://www.quora.com/What-is-the-difference-between-object-detection-and-object-tracking">Object detection and object tracking</a> are two different well established tasks within computer vision:</p><ul><li><strong>Object Detection</strong> is the process of finding instances of semantic objects, e.g. Humans, Cars, Animals.</li><li><strong>Object Tracking</strong> deals with the tracking of a specific instance as it moves around in video or between images.</li></ul><p>In many applications, semantic instances within an view frame are unlikely to change significantly and we can instead track its location using object tracking. (A counter example would be self driving cars — a car driving in opposite lane suddenly changing directions may require different reactions and is semantically very different.)</p><h4>Advantages of Object Tracking</h4><ul><li>Tracking is faster. Intuitively, knowing the speed and previous locations of an object we can infer its current position, regardless if the object is a car or a building.</li><li>Tracking preserves identity. In some applications, we may want to track specific object instances, e.g. track a person with specific identification. Detection cannot differentiate between instances.</li></ul><h4>Object Tracking with OpenCV</h4><p>OpenCV since version 3.1 has a <a href="https://www.pyimagesearch.com/2018/07/30/opencv-object-tracking/">variety</a> of object tracking algorithms available. They are fast, run on regular CPU, and run without additional installation. Platform specific installation for OpenCV, and individual tracker details are not discussed here.</p><p>To use:</p><pre>import cv2</pre><pre># arbitrarily pick KCF Tracker<br>tracker = cv2.TrackerKCF_create()</pre><pre># initialize tracker with a single image frame from video and a bounding box (from detector)<br>tracker.init(frame, box)</pre><pre># predict box coords in next frame<br>box = tracker.update(frame)</pre><h3>Demo</h3><p><a href="https://github.com/twairball/face_tracking">In this example</a> we make a simple face detection app that demonstrates a detector being run every ~6 seconds, and using trackers for the frames in between.</p><p>For face detection in front of a webcam, we can run detector periodically, as the object of interest doesn’t change semantically (still the same face), and then follow the trajectory of the face as it moves across the screen using trackers.</p><p><a href="https://github.com/twairball/face_tracking">twairball/face_tracking</a></p><h4>Pipeline</h4><ol><li>Run detector, get boxes (Green)</li><li>Track boxes for each frame (Blue)</li><li>Update detector periodically or on-demand, and re-create trackers for each box.</li></ol><h4>Results</h4><p>The results from the demo show that we can use the detector once, initialize tracker, and then track the object as it moves around the screen, rather than continuously run detector for every frame.</p><p>If we rely on detector only, we may update the bounding box location every 200ms. That’s 300 calls per minute.</p><p>Using detector + tracking method demonstrated in the repo above, we can run detector every 6 secs, and update bounding box location with tracker much quicker. That’s 10 detector calls per minute. Boom — 97% reduction in detector usage!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*BamK9HQOvlRoS1_ymC8jcQ.gif" /><figcaption>Green box for detector (almost a blink). Blue for tracking.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bb0de7dd512" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lioniq/face-detection-and-tracking-for-real-time-apps-7bb0de7dd512">Face Detection and Tracking for Real-Time apps</a> was originally published in <a href="https://medium.com/lioniq">Lion IQ</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Startup lessons from Doom]]></title>
            <link>https://medium.com/lioniq/startup-lessons-from-doom-bc542bafd6aa?source=rss-593f1c407761------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc542bafd6aa</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[gaming]]></category>
            <dc:creator><![CDATA[Jerry Liu]]></dc:creator>
            <pubDate>Sun, 20 May 2018 13:02:43 GMT</pubDate>
            <atom:updated>2018-05-20T13:02:43.129Z</atom:updated>
            <content:encoded><![CDATA[<p>My first experiences with a PC was with an i386 in my dad’s office, where I learned to free up RAM on DOS to play Wolfenstein3D. Growing up in Hong Kong in the 90s, Nirvana and Oasis may have dominated MTV, but Doom and Deathmatch was what occupied our computers at home and at school.</p><p>I read <a href="http://www.davidkushner.com/book/masters-of-doom/">Masters of Doom</a> for nostalgia and found myself scribbling notes. Intentional or not, id’s success have the hallmarks of textbook startup practices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/140/1*4ngpuZEwvEiOpaPM_YBV2A.jpeg" /><figcaption>Masters of Doom — How two guys created an empire and transformed pop culture</figcaption></figure><h4>Co-founders</h4><p><a href="https://en.wikipedia.org/wiki/John_Carmack">Carmack</a> is the prototypical technical co-founder, while <a href="https://en.wikipedia.org/wiki/John_Romero">Romero</a> played the role of the product co-founder. At the point of their founding <a href="https://en.wikipedia.org/wiki/Id_Software">id Software </a>together, they were already co-workers at Softdisk having launched projects together. Their personalities, background and upbringing could not be more different, but they both shared failed or unremarkable entrepreneurship, and a deep passion for making video games.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*zGb5Mpks0JHlwtnVMSl3XA.jpeg" /><figcaption>Productivity around the world crumbled with the advent of Doom and Deathmatch.</figcaption></figure><h4>Know Your Customers</h4><p>Their target audience was the growing market of gamers, specifically adult gamers with PCs such as the id founders themselves. They lived in a shabby lake house, playing video games and D&amp;D in their spare time. They <em>were</em> their target audience, and Romero was the ultimate gamer himself. The book makes multiple references to how Romero was knowledgeable about everything that was going on in the industry, and would stay actively connected to his gamer customer base.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*FDsQgX2t39cOXq8AKh8xBg.png" /><figcaption>Before the internet era, there was the BBS.</figcaption></figure><h4>Product Market Fit</h4><p>id’s first product titled <a href="https://en.wikipedia.org/wiki/Commander_Keen">Commander Keen</a> tapped into a nascent PC gaming market with a product validated by the popularity of Super Mario Bros. They would follow this recipe through the height of their success: cutting edge technology and user experience. And they were obsessed with both — Carmack would go on to spend months developing new game engines, after which Romero and designers such as Tom Hall would manically produce novel game experience that the world had never seen before.</p><p>Their smash hits, Wolfenstein-3D and Doom, would go on to define their lasting legacy, along with a controversial discussion about violence in video games. I think this bares exceptional note; by and large, their partners at Apogee and GTI would raise market concerns about violence, but Romero would push on with the gore and blood. While the book mentions the decision as a fleeting thought, we can presume that Romero and his founders, simply knew their customers better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*8popxWeiKrdQppMEUHN47w.jpeg" /><figcaption>id Software’s seminal 1993 game: Doom.</figcaption></figure><h4>Viral Marketing</h4><p>Before Youtube and Facebook existed, content and social networks thrived on BBS, where Scott Miller and his fledgling publishing company, Apogee, had built up a wide network of distribution channels for shareware. <a href="https://en.wikipedia.org/wiki/Shareware">Shareware</a> would be the perfect marketing and distribution medium for PC Games in this era. It was a direct-to-consumer distribution model, similar to the one that would come along in the internet era that would disrupt many other industries. Users would have a chance to download the game from a number of BBS sites or servers(resource leverage), try it, and mail in a check if they wanted to buy the full version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uSoqC4Egricka3E01QTtsA.png" /><figcaption>Wolf-3D Shareware would come with 8 levels, after which gamers would call Apogee to buy the full version.</figcaption></figure><h4>Stay Lean</h4><p>They started in a shared house by the lake in Shreveport, and would borrow company PCs at night. Even when they finally moved to Mesquite, Texas, their office would contain only the bare essentials, and the team would not substantially expand until much later in their success. They fired Lane Roathe, a member of their original Gamer’s Edge team because he was not aligned with their PC games vision. They would fire Tom Hall, a founding member, for low productivity on Doom. The ruthlessness would keep their company costs low and their team focused on a singular mission.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*6-I-hVh0-FY-_trET1HZ0A.png" /><figcaption>id’s first Commander Keen game, developed in a little over 3 months.</figcaption></figure><h4>Stay Focused</h4><p>The book paints a frenetic work environment that was described at best like a frat house, where the team literally played games, ate pizza, and made games. Their first Commander Keen game was developed and released in a little over 3 months. This resembles the early days of Facebook or iOS game development. Isolated in their Shreveport lake house, there was no networking events, tech conferences or any of the various industry events that plague us today. Carmack was so singular in his focus that he even retreated to a bland motel room in Florida for a week to work on the Quake 2 engine.</p><p>The story of the rise and fall of id Software leaves many points of discussion among fans and readers. The iconic clash of personalities between Carmack vs Romero would symbolize the opposing mantras of Tech vs Design, the merits of each can still be argued today. Without doubt however, id Software delivered its greatest works with the two of them together.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc542bafd6aa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lioniq/startup-lessons-from-doom-bc542bafd6aa">Startup lessons from Doom</a> was originally published in <a href="https://medium.com/lioniq">Lion IQ</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Product Managers]]></title>
            <link>https://medium.com/lioniq/ai-product-managers-786593996158?source=rss-593f1c407761------2</link>
            <guid isPermaLink="false">https://medium.com/p/786593996158</guid>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Jerry Liu]]></dc:creator>
            <pubDate>Sun, 18 Mar 2018 15:22:05 GMT</pubDate>
            <atom:updated>2018-03-18T23:38:08.417Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently joined an AI company as a Product Manager and I’m having a blast. What do Product Managers do at AI companies and how are our roles different?</p><p>The answer, as many PMs would immediately respond, is that it depends on the product.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ewCsj_7-BGQ_HNyYRBZdQ.png" /></figure><blockquote><strong>Short Answer:</strong><br>AI Product Managers design and build products around datasets and their inherent attributes and distributions. We design products to solve problems, by thinking about what data to feed our AI models.</blockquote><h4>What is an AI product ?</h4><p>If a restaurant adds online delivery service via a mobile app, we would not consider it an internet company. Similarly, if the same restaurant then adds an AI chat-bot or integrates with Amazon Echo to allow customers to place orders by shouting at it, we would not jump to label them as an AI company.</p><p>Simply put, an AI company is one that develops AI technology as a core competency. We can extend this criteria to AI products.</p><p>A consumer travel app that leverages Google Translate, while enhanced with AI super powers, is probably fairly light on AI development and would not likely develop custom translation models.</p><p>A consumer travel app that looks at an exotic plate of food and tells you the name in both your native and its local language, may be developing custom AI models.</p><p>The AI discussions for many PMs today center around strategy for leveraging available solutions. Not every product needs custom AI models (and that’s fine); those that require its teams to invest and develop AI competency will be organized differently.</p><h4>Roles and workflow</h4><p>Teams that do build above mentioned custom AI models optimize for different goals, and naturally have different roles and workflows, such as: <br>• Data collection and management <br>• Machine learning and model development</p><p>Depending on scale of product, the Engineering team may also have additional roles or workflow for: <br>• Model testing &amp; QA<br>• Production model deployment and monitoring</p><p>Typically, PMs at web and mobile product teams work with Design and Engineering members to roll out new products/features. In contrast, AI PMs may coordinate with 2 additional roles: Data team and Model/Algorithms team.</p><p>Working with data at the core of product is not unique to PMs at AI companies. In fact, this may sound very similar to Data Scientists (or PMs that work with them), with a very key distinction; data is used to build AI models, a core part of the product itself. Data science may be a best practice for data driven decision making, but its outcomes are not itself part of a product.</p><h4>Designing AI products</h4><p>Industry leaders today have world class AI labs in addition to deep learning research and engineering teams across various business groups. Deep learning is still a relatively new technology and the industry as a whole is still figuring out best practices. It is clear however, that deep learning AI models are best developed with optimal datasets and designed with laser focused goals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E2D4yeSS-iBFvc_csejL_g.jpeg" /><figcaption>An imaginary travel app that recognizes images of awesome looking food</figcaption></figure><p>Let’s think about the travel app in the earlier example. We want to build an deep learning model to recognize images of food, and tell us the name of the dish.</p><ul><li>Be specific; who are the users, and what data would they feed into the AI models?</li></ul><p>Our users in this case, are regular tourists traveling to exotic places where they might encounter new and exciting looking food. We might assume that users would take pictures of their meals with their smart phones. Our users might come across interesting looking dishes on social media, and want to find out what it is. In this case, it would be important to build dataset with both professional and user generated content, from foreign restaurants such as Hispanic or Asian cuisines.</p><ul><li>Not all datasets are built the same; depending on how you build your dataset for training AI models, you may introduce certain bias to your models.</li></ul><p>One assumption that we might make is that the photos are foodie shots, where the dish is sole subject of the image. What about selfie shots with users eating the food? Or images with multiple dishes on the plate? What about beverages? Datasets have inherent attributes and distributions that may make an AI model more or less effective.</p><p>—</p><p>PMs all think about users and how the product needs to solve a particular problem. AI products look to solve this with deep learning AI models. AI Product managers are responsible to think about the specific task the AI model needs to solve, and what relevant data to feed it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=786593996158" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lioniq/ai-product-managers-786593996158">AI Product Managers</a> was originally published in <a href="https://medium.com/lioniq">Lion IQ</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Neural Network from scratch]]></title>
            <link>https://medium.com/@twairball/neural-network-from-scratch-d0df1cd4eac5?source=rss-593f1c407761------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0df1cd4eac5</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Jerry Liu]]></dc:creator>
            <pubDate>Fri, 20 Oct 2017 16:45:53 GMT</pubDate>
            <atom:updated>2017-10-21T01:41:50.236Z</atom:updated>
            <content:encoded><![CDATA[<p>Coding up a neural network from scratch is a great way to learn and understand what’s going on in a neural network. For experienced readers, this is a great exercise to do from memory.</p><p><strong><em>Repo</em></strong>: <a href="https://github.com/twairball/nn_from_scratch">https://github.com/twairball/nn_from_scratch</a></p><h4>Why write this?</h4><p><a href="http://deeplearning.ai/">Deep learning</a> <a href="http://fast.ai/">resources</a> <a href="https://www.coursera.org/specializations/deep-learning?utm_source=gg&amp;utm_medium=sem&amp;campaignid=917423980&amp;adgroupid=46295378299&amp;device=c&amp;keyword=deep%20learning%20program&amp;matchtype=b&amp;network=g&amp;devicemodel=&amp;adpostion=1t1&amp;creativeid=217989182375&amp;hide_mobile_promo&amp;gclid=EAIaIQobChMIkLSoq7WA1wIVw6FoCh1JewT9EAAYASAAEgJxiPD_BwE">are</a> <a href="https://www.udacity.com/course/deep-learning--ud730">more</a> accessible than ever before, with a plethora of different explanations on the mechanisms of artificial neural networks. While the neural networks have been around for decades, the speed at which deep learning has progressed in the last few years has evolved our understanding of how/why neural networks work. For example, early literature may discuss the “neural” aspects of artificial neural networks (e.g. motivations for the “neuron” and “synapses”). This article will focus on functional implementation because there is a efficient simplicity to how neural networks learn that is worth appreciating.</p><p>This article also borrows from some <a href="https://iamtrask.github.io/2015/07/12/basic-python-network/">great</a> <a href="http://www.wildml.com/2015/09/implementing-a-neural-network-from-scratch/">writeups</a> on the same subject, with its own goal of improving with the following:</p><ul><li>As functional as possible; functional as in Functional Programming. At its core, neural network operations are a series of functional computations.</li><li>Avoid jumping right into object-oriented programming, but <a href="https://github.com/twairball/nn_from_scratch/blob/master/nn_model.py">here is the OOP implementation</a> inspired by <a href="https://keras.io/">great</a> <a href="http://pytorch.org/">frameworks</a> that we have available today.</li><li>Only numpy. It seems obvious now, but tutorials written a few years contained for loops along multiple dimensions.</li><li>Conciseness over brevity; rather than condensing code to as few lines as possible, we aim to encapsulate NN instructions into sensible functions. For example, the main training procedure has 2 instructions.</li></ul><h4>Basics</h4><p>A neural network predicts an output h(z) where z is the weighted sum of inputs x and weights W, plus a bias term b. i.e. z = dot(x, W) + b</p><p>We can extend the neural network to consist of many layers, where each layer computes output h_n using as input h_(n-1) from previous layer, with weights W_n and bias b_n at current layer n.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J8ia4xtVizfvHhOFDOk5nQ.png" /><figcaption>“Neuron” sounds confusing, but its just a node that does simple computation</figcaption></figure><h4>Getting Started</h4><p>Some quick bullet points that outline the implementation steps to our neural network:</p><ul><li>The network is initialized randomly for parameters W_n and b_n.</li><li>We feed input X forward through the network, to get predicted output h, and compare this to our target output Y.</li><li>Output h(z) is computed by a non-linear activation function, such as sigmoid.</li><li>We feed the loss h-Y backwards through the network, and compute how much to adjust our weights W_n and bias b_n using gradient of activation function h(z). This is is back propagation.</li><li>Repeat steps 2 and 3 for a large number of iterations.</li></ul><h4>Gradient math</h4><p>Our activation function will be a sigmoid function, so we’ll need its derivative function to update our weights during back propagation. Luckily, with the <a href="https://en.wikipedia.org/wiki/Chain_rule">chain rule</a>, the derivative of the sigmoid function is <a href="https://math.stackexchange.com/questions/78575/derivative-of-sigmoid-function-sigma-x-frac11e-x">delightfully simple</a>.</p><pre>def sigmoid(x):</pre><pre>    return 1 / ( 1 + np.exp(-x))<br></pre><pre>def sigmoid_deriv(x):</pre><pre>    return x * (1 - x)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*bRDXNqysIfFDYl-vxrtwmQ.jpeg" /></figure><h4>Implementation</h4><p>Let’s build a 3-layer neural network to solve a regression problem, with inputs X and outputs Y:</p><pre>import numpy as np</pre><pre>X = np.array([[0,0,1],[0,1,1],[1,0,1],[1,1,1]]) # shape: (4, 3)</pre><pre>Y = np.array([[0,1,1,0]]).T # shape: (4,1)</pre><p>We also have a couple other constants:</p><pre># regularization term, or learning rate</pre><pre>lr = 0.0001</pre><pre># number of training iterations</pre><pre>n_iters = 60000</pre><ul><li><strong>Initialize weights and biases</strong></li></ul><p>Our network will be a 3–4–1 network, so 3 input nodes, 4 hidden nodes and 1 output node.</p><p>We can think of the weights as the edges that join the nodes in a graph that represents the neural network, and the shape of weights W_n is then (i,j) where i and j are the number of the input and output nodes.</p><pre>def initialize():</pre><pre>    # initialize weights with mean 0</pre><pre>    # network is 3, 4, 1</pre><pre>    W_1 = 2 * np.random.random((3, 4)) - 1 # shape: (3,4)</pre><pre>    W_2 = 2 * np.random.random((4, 1)) - 1 # shape: (4,1)</pre><pre>    # initialize bias as zeros</pre><pre>    # bias shape is same as dimension of W_1, W_2</pre><pre>    b_1 = np.zeros(4) # shape: (4,1)</pre><pre>    b_2 = np.zeros(1) # shape: (1,1)<br></pre><pre>    return [W_1, W_2], [b_1, b_2]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*RC5RDYGYHz4DH5Khlpwd5w.png" /><figcaption>Weights are the edges that join the nodes between layers</figcaption></figure><ul><li><strong>Forward pass</strong></li></ul><p>Our neural network has 3 layers. The 1st layer is just an input, so that’s easy. The subsequent layers are straight forward dot product and activation.</p><pre>def forward_pass(inputs, weights, biases):</pre><pre>    W_1, W_2 = weights</pre><pre>    b_1, b_2 = biases</pre><pre>    h0 = inputs</pre><pre>    h1 = sigmoid(h0.dot(W_1) + b_1)</pre><pre>    h2 = sigmoid(h1.dot(W_2) + b_2)</pre><pre>    return h0, h1, h2</pre><ul><li><strong>Back-propagate</strong></li></ul><p>While the <a href="http://bigtheta.io/2016/02/27/the-math-behind-backpropagation.html">math behind</a> <a href="http://colah.github.io/posts/2015-08-Backprop/">back</a> <a href="http://neuralnetworksanddeeplearning.com/chap2.html">propagation</a> is beyond the scope of this article, we update weights W with the weights gradient dW, as a product of the error gradient h_delta and input h_n.</p><pre>def back_prop(activations, weights, biases):</pre><pre>    h0, h1, h2 = activations</pre><pre>    W_1, W_2 = weights</pre><pre>    b_1, b_2 = biases<br></pre><pre>    # deltas</pre><pre>    h2_loss = Y - h2 </pre><pre>    h2_delta = h2_loss * sigmoid_deriv(h2) # shape (4,1)</pre><pre>    h1_loss = h2_delta.dot(W_2.T)</pre><pre>    h1_delta = h1_loss * sigmoid_deriv(h1) # shape (4,4)</pre><pre>    # dW calculated as dot(input, delta) + regularization term</pre><pre>    dW_2 = h1.T.dot(h2_delta) + lr * W_2</pre><pre>    dW_1 = h0.T.dot(h1_delta) + lr * W_1</pre><pre>    # db calculated as sum of delta</pre><pre>    db_2 = np.sum(h2_delta, axis=0)</pre><pre>    db_1 = np.sum(h1_delta, axis=0)</pre><pre>    # gradient descent update</pre><pre>    weights = [W_1 + dW_1, W_2 + dW_2]</pre><pre>    biases = [b_1 + db_1, b_2 + db_2]</pre><pre>    return weights, biases</pre><ul><li><strong>Training for N iterations</strong></li></ul><p>Training is simply a loop for n_iters iterations, repeatedly doing forward_pass() to compute the activations, and then back_prop() to update the weights and biases parameters.</p><pre>def main():</pre><pre>    weights, biases = initialize()</pre><pre>    # train for N iterations</pre><pre>    for i in range(int(n_iters)):</pre><pre>        activations = forward_pass(X, weights, biases)</pre><pre>        weights, biases = back_prop(activations, weights, biases)</pre><pre>        if (i % 5000) == 0:</pre><pre>            preds = activations[-1]</pre><pre>            loss = np.mean(np.abs(Y - preds))</pre><pre>            print(&quot;[%d] loss: %f&quot; % (i, loss))</pre><h4>Results</h4><p>Run the script python nn.py and we’ll see the neural net go to work:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*TXtgXyBaPvVL0cerVIcKgw.png" /></figure><p>Thanks for reading!</p><p>For seasoned readers experienced with deep learning frameworks, coding a neural network from memory is a great exercise.</p><p>Code for the implementation can be found here: <a href="https://github.com/twairball/nn_from_scratch">https://github.com/twairball/nn_from_scratch</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*Le5RcC35wg__PWndlOgarQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0df1cd4eac5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Neural Machine Translation Today]]></title>
            <link>https://medium.com/lioniq/neural-machine-translation-today-b3beabf80ce4?source=rss-593f1c407761------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3beabf80ce4</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[neural]]></category>
            <category><![CDATA[machine-translation]]></category>
            <dc:creator><![CDATA[Jerry Liu]]></dc:creator>
            <pubDate>Sat, 07 Oct 2017 02:31:31 GMT</pubDate>
            <atom:updated>2017-10-07T02:31:31.657Z</atom:updated>
            <content:encoded><![CDATA[<h4>A brief tour of important concepts to NMT today</h4><p><a href="https://research.google.com/pubs/pub45610.html">In 2016 Google Translate deployed Neural Machine Translation</a> models into production and suddenly, deep learning and the <a href="https://www.nytimes.com/2016/12/14/magazine/the-great-ai-awakening.html">“AI Awakening”</a> was announced to the world. Released in 2006, this would mark the 10th year Google Translate had been in operation to internet users across the world. It would also mark the departure from phrase-based Statistical Machine Translation models to Neural Machine Translation based models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*jRCcDyNvtvhHGhQPRaMH_Q.png" /><figcaption>Google Translate now uses NMT for all its translation</figcaption></figure><p>First introduced by <a href="http://www.aclweb.org/anthology/D13-1176">Kalchbrenner and Blunsom (2013)</a>, Neural Machine Translation models started to be competitive at academic machine translation conferences in 2015, and <a href="http://www.statmt.org/eacl2017/practical-nmt.pdf">by 2016</a> had surpassed SMT in almost all language translation tasks.</p><p>While the achievements of NMT are numerous and rapid, we will highlight a few papers and concepts that have defined NMT today. We will also touch on a couple recent papers to try and infer where NMT is headed.</p><h4>Sequence to sequence learning</h4><p>The seminal paper by <a href="https://arxiv.org/abs/1409.3215">Sutskever et al (2014)</a> introduced sequence to sequence learning (seq2seq), a method using Recurrent Neural Networks for both encoder and decoder. To address the issue of vanishing gradients that plague deep RNN models, they use <a href="http://colah.github.io/posts/2015-08-Understanding-LSTMs/">Long Short-Term Memory networks</a>. The paper also note some important observations:</p><ul><li>seq2seq have no trouble with long sentences, but performs better on long sentences when the source sentence is fed into the network in reverse.</li><li>seq2seq learns sensible phrase and sentence representations that are sensitive to word order.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K1TUbSLXmJsxA_b4Fgho0Q.png" /><figcaption>sequence to sequence learning, using LSTMs</figcaption></figure><h4>Attention Mechanisms</h4><p>In LSTM seq2seq models, the decoder generates translation based on only the last hidden state of the encoder. Empirically, translation quality is worse for longer sentences.</p><ul><li>Models can improve by feeding source sentences in reverse.</li><li>Models can improve by feeding an input sequence twice.</li></ul><p>The seminal work of <a href="https://arxiv.org/abs/1409.0473">Bahdanau et al (2014)</a> introduced attention mechanisms to seq2seq models. Attention mechanisms allow connections between each encoder and decoder hidden states, so that the target word will be predicted based on combination of context vectors, rather than just the previous hidden state of the decoder. Intuitively, this makes sense; only a small portion of the source sentence is relevant to translating a target word.</p><p><a href="http://www.statmt.org/eacl2017/practical-nmt.pdf">In 2016, NMT Attention models achieved top results</a> at almost all translation tasks. The achievements of attention mechanisms are so good, that Chris Manning once opined that you could throw <a href="https://simons.berkeley.edu/sites/default/files/docs/6449/christophermanning.pdf">bi-LSTMs at any task in NLP</a>, (and add attention if you need information flow).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*cAB9HzB41fDdjZFTHWhZFQ.gif" /><figcaption>seq2seq with attention. Purple lines demonstrate attention mechanism. image from <a href="https://research.googleblog.com/2016/09/a-neural-network-for-machine.html">https://research.googleblog.com/2016/09/a-neural-network-for-machine.html</a></figcaption></figure><p>There is an additional side bonus to attention mechanisms; they can be used to visualize the contributing weight of each source word or subword to each target word, making attention mechanism more interpretable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*603L2RM910ghxaFagj6JIw.jpeg" /><figcaption><a href="https://arxiv.org/abs/1409.0473">Bahdanau et al (2014)</a></figcaption></figure><h4>Subword Encoding</h4><p>NMT typically operate with a fixed vocabulary, but translation is an open-vocabulary problem. Rare or unknown words (or worse, spelling errors) are a problem for NMT as it relies on word embeddings. NMT models don’t have an array of grammar and language components as in SMT models.</p><p>Previously, sentences were fed into NMT models as a series of word tokens, and a variety of methods studied this problem.</p><ul><li>Increase the size of the source and target vocabulary. However this increases the training time and decoding complexity.</li><li>Tokenize at character level. This would make the vocab size very small, but increase the length of sequences, again increasing training time and decoding complexity.</li><li>Handle rare or unknown words via other methods such as using dictionary methods, or use part-of-speech taggers to recognize the word or phrase as proper nouns.</li></ul><p><a href="https://arxiv.org/abs/1508.07909">Sennrich et al (2016)</a> introduced subword units, and provided an argument that word tokens are not optimal. To build a vocabulary of subwords, the paper adapts Byte-Pair Encoding, a compression algorithm, to word segmentation.</p><ul><li>BPE is more efficient than storing all known words. It is after all, a compression algorithm.</li><li>At worst, a word string can be encoded as a series of characters, and avoids complicated dictionary fallbacks. As an open vocabulary strategy, this eliminates out-of-vocab words.</li><li>While the paper is titled as a strategy to deal with rare words, subword encoding outperforms full-word encoding across the board, including language pairs that don’t share alphabets such as English to Chinese.</li></ul><h4>Convolutional Sequence to Sequence learning</h4><p>The dominant approach to NMT thus far encodes source sentences with a series of bi-directional LSTMs and generates a variable length output with another set of decoder RNNs, both with attention mechanisms. Convolutional neural networks are commonly applied with great success in image recognition tasks and have several advantages, chiefly being parallelization for GPU processing. RNNs in comparison maintain a hidden state that depend on the previous hidden states in the sequence.</p><p>Facebook AI’s <a href="https://arxiv.org/abs/1705.03122">Gehring et al (2017)</a> present a fully convolutional architecture, which create hierarchical representations over the input sequence in which nearby input elements interact at lower layers while distant elements interact at higher layers. Although convolution filters have fixed width kernels, by stacking convolution layers all the words or subwords in a sentence are eventually connected, capturing long range dependencies.</p><p>For the model to be competitive the authors also devised additional architecture designs:</p><ul><li>Positional embeddings added to the input embeddings, to capture a sense of sequential order.</li><li>Multi-step attention, where attention is computed using current decoder state and embedding of previous target word token.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*4VcPjnkVlUQhzj5d-GBp4A.gif" /></figure><p>While previous convolutional methods were unable to unseat the LSTM Attention hegemony, ConvS2S achieves state of the art results surpassing previous bi-LSTM attention models while easily reducing training time by an order of magnitude.</p><p>This achievement raises the question; if sequence to sequence learning can be learned without using RNNs, do attention mechanisms contribute much more to NMT than we think?</p><h4>Attention is all you need</h4><p>Google Brain’s <a href="https://arxiv.org/abs/1706.03762">Vaswani et al (2017)</a> propose a new architecture, the Transformer, based solely on attention mechanisms. Instead of recurrent or convolutional layers, Transformer introduces “self-attention” layers in the encoder and decoder.</p><p>Self-Attention layers connects all subword embeddings in the sentence, effectively allowing the network to learn inter-dependencies in constant time. This mechanism addresses the issue of long-range dependencies that have plagued RNN architectures. While ConvS2S addresses this issue using a stack of convolution layers, the path length would still be O(n/k).</p><p>To facilitate self-attention layers, the paper introduces multi-head attention mechanisms. Rather than learning a single attention function, multi-head attention learns and concatenates 8 different attention functions to form an output context vector. Attention is relatively simple calculation compared to recurrence or convolution, and multi-head attention can be parallelized efficiently. Intuitively, self-attention is learning a positional interdependency between individual subwords in source, and target sentences. As a side bonus, this makes self-attention more interpretable than recurrent or convolution layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-yqFB-temsB80f0QSbWlmQ.png" /><figcaption><a href="https://arxiv.org/abs/1706.03762">Vaswani et al (2017)</a></figcaption></figure><p>With the Transformer model setting a new benchmark score, this would mark the second time in 2017 that the bar was raised yet again by a non-recurrent model. Even more impressively, the Transformer model displays remarkable efficiency, with a base model whole orders of magnitude faster than even ConvS2S.</p><p>I think this marks an exciting time in Neural Machine Translation as we start to see more efficient representations of translation learning. Its not clear yet if the new architectures have ended the dominance of LSTM Attention models, but a new class of models that are faster to train and would make NMT experimentation more accessible and repeatable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/180/1*JKAlFe65sCscATEK59zG1A.png" /><figcaption>We’re not there yet, but we’re making big strides</figcaption></figure><h4>Frameworks</h4><p>With a multitude of open source software, NMT has never been more available and accessible to amateurs and startups alike.</p><ul><li><a href="https://github.com/tensorflow/nmt">Tensorflow-NMT</a> is a great place to start for beginners, and has a fantastic tutorial to explain many NMT concepts in practical code.</li><li><a href="https://github.com/EdinburghNLP/nematus">Nematus</a> is a fully featured NMT framework that the University of Edinburgh team has used to consistently place top results at WMT.</li><li><a href="https://github.com/facebookresearch/fairseq">Fairseq</a> is a seq2seq and convS2S framework from Facebook AI based on Torch. I personally find it to be very fast.</li><li><a href="https://github.com/tensorflow/tensor2tensor">Tensor2Tensor</a> is a fantastic framework used by the Transformer paper authors. It has a very comprehensive end-to-end approach to NMT experiments.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3beabf80ce4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lioniq/neural-machine-translation-today-b3beabf80ce4">Neural Machine Translation Today</a> was originally published in <a href="https://medium.com/lioniq">Lion IQ</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How good is Neural Machine Translation ?]]></title>
            <link>https://medium.com/lioniq/how-good-is-neural-machine-translation-dde75c202cbe?source=rss-593f1c407761------2</link>
            <guid isPermaLink="false">https://medium.com/p/dde75c202cbe</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[neural]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-translation]]></category>
            <dc:creator><![CDATA[Jerry Liu]]></dc:creator>
            <pubDate>Wed, 04 Oct 2017 03:07:56 GMT</pubDate>
            <atom:updated>2017-10-04T03:14:12.933Z</atom:updated>
            <content:encoded><![CDATA[<p>Deep Learning drew a lot of attention for Google Translate’s successful deployment in a consumer product back in 2016. (Feels like it was so long ago!) So, how good is Machine Translation today, and is it “solved”?</p><p><em>(This blog post is an extended adaptation of a talk I gave at Shanghai Machine Learning Meet-up in Sep 2017)</em></p><h4>Is Machine Translation solved?</h4><p>Translation seems like a task very well suited to AI. The idea of a device or intelligent robot that is able to translate and converse alien languages has graced many popular science fiction. Today, the consumer consensus is to turn on Google Translate (or Baidu / Youdao / Sogou if you’re in China) and accept the fact that the results gets you most of the way there, with weird “lost-in-translation” sentences here and there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/160/1*k-12ExHeMzAELObmrEeKcQ.jpeg" /><figcaption>We might get self-driving cars before we solve AI translation?</figcaption></figure><p>Many if not all of my expat friends in China have trouble using Baidu Maps, despite some having lived in China for a number of years. This is a strange phenomenon in 2017; sometimes the VPN app works but Google Maps still has trouble finding a few locations, and often has outdated navigation.</p><p>So I built <a href="http://mapcaptain.io/">Map Captain</a>, a mobile app to translate English/Chinese search queries and directions on top of Baidu Maps. Map apps used by local people in a foreign country is always superior to a tourist map resource, we just need to remove the language barrier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/192/1*v3Y8p-3H0AVPkGuTYHQSRw.png" /><figcaption>China maps in English. <a href="http://mapcaptain.io/">http://mapcaptain.io</a></figcaption></figure><p>Along the way, I wanted to know how good was state of the art machine translation, and in particular, English-Chinese translation.</p><h4>A brief history of Machine Translation</h4><ul><li>1950: Georgetown Experiment 60 Russian-English sentences</li><li>1980s: Statistical Machine Translation</li><li>1996: Systran / Alta-Vista babelfish</li><li>2006: Google Translate</li><li>2007: MOSES open source statistical MT framework</li><li><a href="http://www.aclweb.org/anthology/D13-1176">2013: Pure Neural MT system presented</a></li><li>2014: Competitive NMT (<a href="https://arxiv.org/abs/1409.0473">Bahdanau et al</a>, <a href="https://arxiv.org/abs/1508.04025">Luong et al</a>)</li><li>2016: NMT achieves top results at WMT’16</li><li>2016: <a href="https://research.google.com/pubs/pub45610.html">Google Neural Machine Translation (GNMT)</a></li></ul><p>Machine translation (MT) has a brief but rich history, and starts as all machine learning domains do, with a parallel corpus. The <a href="https://en.wikipedia.org/wiki/Rosetta_Stone">Rosetta Stone</a>, is a famous parallel corpus carved on a stone slab, that allowed us to learn Ancient Egyptian, which at the time was an unknown language. Today, MT systems have vastly larger datasets since tapping into the web. The history of Statistical Machine Translation is decorated with many achievements, but out of scope of this article.</p><p>Neural Machine Translation, the application of deep neural networks for machine translation, has only hit the scene a few years ago, but has since made big sweeps across many translation tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*G-ss7btzHdVVCaNZKWJIOg.jpeg" /></figure><h4>Is Neural Machine Translation the New State of the Art?</h4><p>In the study <a href="https://ufal.mff.cuni.cz/pbml/108/art-castilho-moorkens-gaspari-tinsley-calixto-way.pdf">“Is Neural Machine Translation the New State of the Art?” (2017)</a> the authors compare Neural Machine Translation (NMT) versus Statistical Machine Translation (SMT) across three domains:</p><ul><li>E-commerce Product Listing (En-De)</li><li>Patent Titles and Abstracts (Zh-En)</li><li>MOOC content (En-De, En-EL, En-Pt, En-Ru)</li></ul><p>In their abstract, they note: <em>“Automatic Evaluation results presented for NMT are very promising, however human evaluations show mixed results”. </em>This is in line with typical consumer experience of tools such as Google Translate.</p><p>The Patent Titles and Abstracts study is particularly interesting, as it is a collection of legal documents written in Chinese. Firstly, most academic research in NMT compares results of western languages such as English-German or English-French. Chinese and English don’t share any alphabet or common word stems compared to western languages that share Latin origins. Secondly, we can expect that in a collection of Chinese legal documents written with terse technical jargon there would be a large vocabulary of words that a model may not have seen often in its training data. The NMT system in this case fared poorly compared to the SMT system which may have specified features and language models.</p><blockquote>In summary, NMT wins in the MOOC automatic evaluation, does poorly when it sees words/phrases it doesn’t know, and is bad at Chinese.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*K5jGFZIXEJZqCfK11PjFuw.png" /></figure><h4>Is Neural Machine Translation ready for deployment?</h4><p><a href="https://arxiv.org/abs/1610.01108">In this 2016 study</a>, the paper authors compare translation quality of phrase-based SMT and NMT across a wide range of language pairs. The study is conducted on the United Nations Parallel Corpus which is available in six languages.</p><p>With the exception of French-Spanish, NMT outperforms SMT across the board. Particularly impressive are the translation results involving Chinese. It should be noted however, that these are the worst performing SMT results, suggesting SMT results in these experiments could have some margin of improvement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X63uYBz-7wvT3A0fkHmYwg.png" /><figcaption><a href="https://arxiv.org/abs/1610.01108">https://arxiv.org/abs/1610.01108</a></figcaption></figure><p>A second chart shows translation results with English as one of the language pairs. Hiero, a hierarchical phrase based SMT system confirmed to outperform phrase based SMT in Chinese-English translation is added to the experiment. In all cases, NMT outperforms all SMT, and still outperforms Hiero by a significant margin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OeOFkD05D68dxVJoe2xPJw.png" /><figcaption><a href="https://arxiv.org/abs/1610.01108">https://arxiv.org/abs/1610.01108</a></figcaption></figure><p>In summary, the paper conducted a study on an open six-way dataset and compared 30 language pairs and found NMT to outperform SMT in 29 of them, with particularly large gains in Chinese.</p><blockquote>This contrasts with the results in above section, suggesting that seasoned SMT systems with rich feature engineering adapted to specific domains still set a high bar for NMT to catch up to.</blockquote><h4>Where are we now?</h4><p><a href="http://www.statmt.org/eacl2017/practical-nmt.pdf">NMT systems achieved top results at most language pairs at WMT’16</a>, and it is no coincidence that Google, Baidu, and other commercial NMT deployments also launched in 2016.</p><p>In a study of human evaluation of NMT, <a href="https://arxiv.org/pdf/1510.05203.pdf">Neubig et al</a> find that NMT results are more fluent and more grammatical than SMT results. They find that NMT generates results with more accurate word order, but also note that NMT results generally favor more common words, citing the example of mistaking “radiant heat” as “radiation heat” or “slipring” as “ring.”</p><p>Translation by nature is open vocabulary; the sentences encountered at testing may very well be unknown during training. There have been many different methods to address the issue of unknown or rare words (or worse, spelling mistakes) and is a broad topic onto itself. We will just briefly mention here that most of the <a href="http://www.statmt.org/wmt17/pdf/WMT17.pdf">top NMT results at WMT’17</a> use <a href="https://arxiv.org/abs/1508.07909">Byte-Pair Encoding to segment words into subword units</a> to address this issue.</p><p>Parallel translation corpus are particularly costly, and deep neural networks need large training datasets to work efficiently. While there are more datasets available for researchers and startups to work on today, we still lack resources in domain specific corpus to work on domain adaptation.</p><p>Perhaps the most well known problem for Neural Machine Translation is the expensive training cost; modern state of the art models take days to train on multiple GPU.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AyvtIYQsIZBqGqlWg6mZlQ.png" /><figcaption><a href="https://research.googleblog.com/2017/06/accelerating-deep-learning-research.html">https://research.googleblog.com/2017/06/accelerating-deep-learning-research.html</a></figcaption></figure><p>Compared to image recognition problems, Neural MT don’t currently have well studied transfer learning properties to bootstrap model training.</p><h4>Closing summary</h4><ul><li>NMT has achieved state of the art MT, but is far from solved.</li><li>Methods to deal with open vocabulary are an important part of NMT.</li><li>NMT models are still very expensive to train.</li></ul><p>There is a lot going on in Neural Machine Translation, and the field has made rapid strides in recent years. Just as image recognition made leaps to surpass human vision accuracy, hopefully we will continue to make strides towards surpassing human translation accuracy.</p><p>—</p><p>Comments welcome!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dde75c202cbe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lioniq/how-good-is-neural-machine-translation-dde75c202cbe">How good is Neural Machine Translation ?</a> was originally published in <a href="https://medium.com/lioniq">Lion IQ</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Predicting Indoor Air Quality]]></title>
            <link>https://medium.com/lioniq/predicting-indoor-air-quality-f38fdd60348d?source=rss-593f1c407761------2</link>
            <guid isPermaLink="false">https://medium.com/p/f38fdd60348d</guid>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[air-quality]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Jerry Liu]]></dc:creator>
            <pubDate>Fri, 30 Jun 2017 14:00:25 GMT</pubDate>
            <atom:updated>2017-09-20T01:15:52.619Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/474/0*MmR3STI1Z4aDyyUt." /></figure><p>Air quality monitoring, like weather forecasting, is incredibly complex. This blogpost explores a deep learning approach to forecast indoor PM2.5 air quality with a type of recurrent neural networks called Long Short-Term Memory (LSTM).</p><p><a href="http://www.measureofquality.com/">GAMS</a> provides indoor air quality monitoring for commercial venues such as schools and offices. Their monitors record indoor air metrics such as PM2.5, CO2, etc and sends them to their backend every minute or so. IoT data is interesting because they are naturally data-rich, regular (numeric floats) and automatically framed in a time series.</p><p>Our project with GAMS was to build a prototype to predict PM2.5 in the near future, e.g. look at last N hours and predict next hour measurement. Typically, a data scientist may approach the problem by exploring various correlations between the columns. Our approach will instead model air quality measurements as time series, using recent history to predict near-future measurements, i.e. predict <em>Xi</em> given <em>[X(i-1), X(i-2), X(i-3)…, X(i-k)]</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/0*ZQkrEhZqkEfZXB-l." /></figure><p><strong>Long Short-Term Memory Networks</strong></p><p>A glaring limitation of Vanilla Neural Networks (and also Convolutional Networks) is that their API is too constrained: they accept a fixed-sized vector as input (e.g. an image) and produce a fixed-sized vector as output (e.g. probabilities of different classes) [1]. Recurrent neural networks allow us to operate over a sequence of inputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/188/0*gUgJ8ZN0HJb0W8Sc." /></figure><p>Long Short Term Memory networks — usually just called “LSTMs” — are a special kind of RNN, capable of learning long-term dependencies. They were introduced by <a href="http://deeplearning.cs.cmu.edu/pdfs/Hochreiter97_lstm.pdf">Hochreiter &amp; Schmidhuber (1997)</a>, and were refined and popularized by many people in following work. They work tremendously well on a large variety of problems, and are now widely used. [2]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/0*5-iCdGI4uhcI7w-L." /></figure><p><strong>Dataset</strong></p><p>The dataset [3] consist of several air quality measurements recorded from our IoT device in an undisclosed office space in Shanghai, as well as public outdoor air quality recordings from nearby US Consulate station.</p><p>The dataset is described in detail in this <a href="https://lioniq.wordpress.com/2017/06/28/introducing-gams-dataset/">blog post</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*wgUDt2_bdOaCtnCF." /></figure><p><strong>Prototyping</strong></p><p>Before we feed our data into our LSTM, we need to “roll up” our data. Suppose at time step <em>i</em>, we will use historical data from <em>i</em> to <em>i-k</em> to predict measurement at time <em>i+n</em>. Therefore, our input data needs to have for each row <em>i</em>, an array of tensors <em>[X(i), X(i-1), … X(i-k)]</em>. Our labels would have for each row <em>i</em> our target value <em>X(i+n).</em></p><p>Let’s use a simple example of looking back past 3 hours of data, to predict PM2.5 1 hour in the future. (Note: we’ll want to do some kind of back and forward filling to avoid NaNs)</p><pre>def preprocess(features, labels, timesteps=3, ahead=1): &quot;&quot;&quot; Create dataset with timesteps, in sync with labels &quot;&quot;&quot; dataX, dataY = [], [] for i in range(len(features) - timesteps - 1): x = features[i:(i + timesteps), :] dataX.append(x) dataY.append(labels[i + timesteps + ahead -1, ]) return np.array(dataX), np.array(dataY) # generate data for input to LSTM labels = dataset[3] # suppose pm25 is in column=3 X_train, Y_train = preprocess(dataset, labels, timesteps=3, ahead=1)</pre><p>We can then feed the preprocessed inputs into an LSTM. With Keras, the model is something like this:</p><pre>from keras.models import Sequential, Model from keras.layers import Input, LSTM model = Sequential() model.add(LSTM(8, input_shape=X_train.shape)) model.add(Dense(1)) model.compile(loss=&#39;mean_squared_error&#39;, optimizer=&#39;adam&#39;)</pre><p>There are some hyper parameters to play with, and the network can be more sophisticated by “stacking” LSTM layers on top of each other. For our purpose of predicting <em>X_pm25(i+1)</em> given <em>X(i), X(i-1), X(i-2)</em>, a simple network can capture some of the sequential relevance of the data (and more importantly, runs on CPU just fine).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*9A17MxeBA2urvZrj." /></figure><p><strong>Whats next</strong></p><p>The above experiment outlines our prototype for predictive analytics for IoT data powered by deep learning and LSTMs. There’s still alot of work left to go from a Jupyter notebook plot, to an actual product!</p><ul><li>Data loaders to read from, and also write predictions back to production data stores, e.g. Influxdb, or Spark.</li><li>Model loaders and continuous update</li><li>Configurable models, to allow us to run multiple models with different parameters</li><li>Monitoring to evaluate models — TensorBoard is a good candidate.</li><li>Asynchronous pipelines, so we can run multiple models in production</li><li>Deployment and containers — this is underrated and seriously not trivial for deep learning platforms.</li></ul><p><strong>References</strong></p><ul><li>[1] <a href="http://karpathy.github.io/2015/05/21/rnn-effectiveness/">http://karpathy.github.io/2015/05/21/rnn-effectiveness/</a></li><li>[2] <a href="http://colah.github.io/posts/2015-08-Understanding-LSTMs/">http://colah.github.io/posts/2015-08-Understanding-LSTMs/</a></li><li>[3] <a href="http://www.measureofquality.com/">http://www.measureofquality.com/</a></li><li>[4] Long Short Term Memory, <a href="http://dl.acm.org/citation.cfm?id=1246450">http://dl.acm.org/citation.cfm?id=1246450</a></li></ul><p><em>Originally published at </em><a href="https://lioniq.wordpress.com/2017/06/30/predicting-indoor-air-quality/"><em>lioniq.wordpress.com</em></a><em> on June 30, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f38fdd60348d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lioniq/predicting-indoor-air-quality-f38fdd60348d">Predicting Indoor Air Quality</a> was originally published in <a href="https://medium.com/lioniq">Lion IQ</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing GAMS Dataset]]></title>
            <link>https://medium.com/lioniq/introducing-gams-dataset-23542239d6de?source=rss-593f1c407761------2</link>
            <guid isPermaLink="false">https://medium.com/p/23542239d6de</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[air-quality]]></category>
            <dc:creator><![CDATA[Jerry Liu]]></dc:creator>
            <pubDate>Wed, 28 Jun 2017 13:19:04 GMT</pubDate>
            <atom:updated>2017-09-20T01:13:37.854Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/318/0*G16jpjjxDcl9mJXd." /></figure><p>In conjunction with GAMS, we have released an indoor air quality dataset. GAMS provides air quality monitors for commercial spaces, such as schools and offices. Their monitors record indoor air metrics such as PM2.5, CO2, etc and sends them to their backend.</p><p>The dataset consists of indoor and outdoor measurements (total 13 columns) from Nov 2016 to March 2017 (total 135k rows).</p><p>The dataset is available for academic and educational uses. We hope people find this useful, please reference <a href="http://www.measureofquality.com/">www.measureofquality.com</a> in any subsequent works. (For commercial license please contact GAMS)</p><p>Github repo: <a href="https://github.com/twairball/gams-dataset">https://github.com/twairball/gams-dataset</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*CK0ExfsIMff3W1t-." /></figure><p><em>Originally published at </em><a href="https://lioniq.wordpress.com/2017/06/28/introducing-gams-dataset/"><em>lioniq.wordpress.com</em></a><em> on June 28, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23542239d6de" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lioniq/introducing-gams-dataset-23542239d6de">Introducing GAMS Dataset</a> was originally published in <a href="https://medium.com/lioniq">Lion IQ</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>