<?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 Ramos on Medium]]></title>
        <description><![CDATA[Stories by Ramos on Medium]]></description>
        <link>https://medium.com/@ra-mos?source=rss-e17553b8e2c5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KDfpR5KKP5nFDUpL8FD_Dw.jpeg</url>
            <title>Stories by Ramos on Medium</title>
            <link>https://medium.com/@ra-mos?source=rss-e17553b8e2c5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 19:35:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ra-mos/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[Get up an running with Local SSDs on Kubernetes (GKE)— p1 the code.]]></title>
            <link>https://ra-mos.medium.com/get-up-an-running-with-local-ssds-on-kubernetes-gke-p1-the-code-c6cf5ac7ae71?source=rss-e17553b8e2c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6cf5ac7ae71</guid>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[ssd]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Ramos]]></dc:creator>
            <pubDate>Sun, 07 Mar 2021 20:03:18 GMT</pubDate>
            <atom:updated>2021-03-07T20:03:18.696Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4qYnOvgJjhMG-hLHmFgN_g.png" /></figure><p>Data Gravity &amp; Fast retrieval; Referenced on GCP/GKE; Code Examples;</p><h4>Intro</h4><p>Your data storage system (SSD, HDD) is the slowest part of your data-application hardware stack compared to other hardware such as CPU, RAM, or GPU. You can’t escape this in cloud. As AI continues to commoditize, along with cloud native solutions, you’ll soon discover that decoupled infrastructure/hardware present unique challenges for hardware config that is vital to performance.</p><p>Cloud providers, like Google, provide amazing hardware capabilities &amp; here I’ll briefly cover an approach for a Kubernetes/GKE architecture that can benefit from proper hardware config and management; offering low data gravity and advanced performance for a read-only volume. This requires some OS-level “hacking”, disk ops, and coverage of embedded db software that make efficient use of SSDs and I/O bound workloads.</p><h4>Scenario</h4><p>You need to formate multiple SSDs on GKE nodes. You want RAID0 for single mount vs multiple partition. You are using helm.</p><p>K8’s doesn&#39;t enable one-time scripts for nodes, but you can use Daemonset and init-containers with advanced privileges to achieve one-time scripts/jobs. Run these very carefully, know what you are doing.</p><h4>Code Example — Single mount multiple SSDs on GKE Node</h4><p>Here is the daemonset. We will breakdown the security settings, nsenter, wait hacks, and mounting in another post.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8560c09be1418c313a9775de3f649bbe/href">https://medium.com/media/8560c09be1418c313a9775de3f649bbe/href</a></iframe><p>Here is the configmap with the script that formats up to 24 SSDs. Some of this will change depending on your node type.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3d410963cf391b6f6020d86d64200d9/href">https://medium.com/media/e3d410963cf391b6f6020d86d64200d9/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6cf5ac7ae71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design Thoughts: Retail Engagement Platform — Intro & Mobile]]></title>
            <link>https://ra-mos.medium.com/design-thoughts-retail-engagement-platform-intro-mobile-68d9dbe78102?source=rss-e17553b8e2c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/68d9dbe78102</guid>
            <category><![CDATA[product-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[retail]]></category>
            <category><![CDATA[system-architecture]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Ramos]]></dc:creator>
            <pubDate>Wed, 28 Mar 2018 18:43:21 GMT</pubDate>
            <atom:updated>2018-07-27T00:08:20.616Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*xufs7qky1UqguE-E.png" /></figure><p>This is a personal exploratory dive into what a disruptive “retail engagement platform” (REP) would look like. My perspective here is someone with experience in IoT-related work, consumer-banking digital experiences in retail, and platform architecture in private &amp; federal enterprise. This writing is also a bit more startup-focused. Big enterprise will have a different pov, and their type of REP might be more broad or “sophisticated”, &amp; involve more of a platform-scope incorporating existing systems. The design we’ll cover is really centered around a single customer experience/product with no legacy or existing platform bindings.</p><p>Product vision &amp; design are out of scope here, however, this is an outline encompassing possible system architecture of a customer experience that filters into a REP. This first part covers the customer experience (mobile development and integration), whereas future parts will cover overall platform design.</p><p><strong>Note: </strong>Though this is startup focused, many of the same archtictural guides could apply to enterprise, especially in relation to IoT, serverless, &amp; container workflows. Cloud computing capabilities, &amp; even on-prem, have expanded to allow greater abstractions that both enterprise and startups will take advantage of. We will cover these in the overview of PaaS, Serverless (lambda, gcp, k8s capabilities), and lower level implementations with containers &amp; Kubernetes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*LKS7Vv0Bc_IzQDAH.jpg" /><figcaption>Illustration by Kagan McLeod — found on therealdeal.com</figcaption></figure><p>Retail is experiencing a revolution (others would like to call it an apocalypse). The revolution might not fare well for many brick-and-mortar stores, but it certainly leaves room for unsuspected disruption, survival, and reemerging dominance in the space.</p><p>Basic — probably naive — Overview: To survive &amp; thrive retail solutions need to provide better engagement with customers. Currently, it is not enough to only offer a solid experience in-store (still is a major factor), predictable irrational tactics, or selling products consumers simply need/want. Engagement needs to happen outside of the store as well, and in a way that drives more traffic. Value needs to not only be derived from data, but provided to the customer with the ability to rapidly iterate and adapt. A platform needs to enable balanced product teams (Product Manager, Developers, &amp; User-Centric-Designers) to deliver solutions continuously.</p><h4>1. The Customer Experience — Mobile Application</h4><p>Possibly the most crucial aspect of this all is the customer experience (a product essentially). It is the most visible in the value-chain. Without diving into product design, we’ll keep our customer experience in the scope of <strong>a mobile application that drives a user to engage with a retailer</strong> (in &amp; out of stores). Our goal in the rest of this writing is to architect this application. I do have a vision for a particular product, and it incorporates IoT (any demo I code up will as well)… so we <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Bluetooth_API">aren’t considering web or PWA’s</a> — but these are still great and would be used for retail-side applications.</p><p>How should we develop the customer app?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*SMF7prun2sUghBHr5xREFw.png" /></figure><p><em>Remember that we have the perspective of a small startup </em>— we want to be able to rapidly build and to keep things simple &amp; we might not have the people to code both Android and iOS.</p><p>So, React Native? — I was an early adopter of React and advanced quickly with it. I would choose it for a complex web UI any day, but not for a mobile app. The app is the ultimate enabler of customer engagement. It will need interfaces to things such as Bluetooth LE (<em>iBeacon &amp; Eddystone for in-store engagement</em>), NFC/RFID <em>(in-store engagement)</em>, GPS &amp; mapping <em>(location-based services for out of store)</em>, and possibly other sensor or IoT <em>(indoor tracking?)</em>. It’ll need real-time communication interfaces <em>(socket, rpc)</em> and stellar integration <em>(SDKs)</em>. I’ve used React Native successfully, but only when creating fast POCs or UI/UX focused work. I do not feel that it offers simplicity for what we need, other than rapid development — I’m not saying it isn’t possible to do all of those things with React Native, but I don’t believe it would be clean and would present many challenges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*iQz_pQ8l2B_JU_8AJn9wVQ.png" /></figure><p><strong>We are going platform-native here</strong> &amp; will develop separately for both Android and iOS. Win for static-types… I hope the JS community can understand. We are giving up the easy option, &amp; yea more work here is a tough sell, however it feels like the right move as an engineer — and we can still utilize libraries such as <a href="https://github.com/facebook/yoga">https://github.com/facebook/yoga</a> for cross-platform development.</p><p><em>“Simplicity is hard work. But, there’s a huge payoff. The person who has a genuinely simpler system — a system made out of genuinely simple parts, is going to be able to affect the greatest change with the least work. He’s going to kick your ass. He’s gonna spend more time simplifying things up front and in the long haul he’s gonna wipe the plate with you because he’ll have that ability to change things when you’re struggling to push elephants around.” </em>— Rich Hickey</p><p>There are a few more things that play an important part with our initial mobile app and overall system: User Management, Push Notifications, Metrics, &amp; CI/CD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*w4gtM8MEto_YnzmpYVZQwg.png" /></figure><p>We aren’t developing any of these things from scratch. The product/app experience will be the only custom development piece. There are many great and affordable/cheap services that give us (a broke startup) all we could possibly want to launch. <em>Again, we aren’t a large enterprise whose platform would look different and might already incorporate these features.</em></p><p><strong>User Management, Push Notifications, Metrics</strong></p><p>The most significant consideration right now is User Management. Our contenders here include <a href="https://firebase.google.com/docs/auth/">GCP Firebase</a>, <a href="https://aws.amazon.com/cognito/">AWS Cognito</a>, &amp; <a href="https://auth0.com/">Auth0</a> (sorry Azure). I love the work that Auth0 does, but I think the choice of user management will play an important role in the overall system. Our future platform stack will need to integrate seamlessly with user management. That leaves Firebase and Cognito, which might ultimately mean Google Cloud Platform vs Amazon Web Services for our infrastructure/platform setup. This is a tough call right now. The same goes for push notifications and metric &amp; reporting services.</p><p><strong>It’s a safe bet use either GCP (Firebase) or AWS (Cognito, Pinpoint) </strong>for all of these needs right now<strong>. </strong>Pricing is similar &amp; both offer free-tier structures. We don’t want our mobile needs to be the ultimate decider of GCP vs AWS, so we wont to choose at this point.</p><p><strong>CI/CD</strong></p><p>Here is what we need out of CI/CD:</p><ul><li>Build and sign the app</li><li>Upload to app stores</li><li>Things like <a href="https://hockeyapp.net/features/feedback/#s">HockeyApp</a> integration</li><li>Run Unit and UI tests continuously on release and develop branches</li><li>Build each Merge Request and report test results back.</li></ul><p>We will need our overall CI system to integrate nicely with our choice here… but we’re in a similar situation as above &amp; not in the best spot to choose that until we cover other aspects of our REP. However, we can select a tool that will satisfy our mobile deployment &amp; build needs. <a href="https://fastlane.tools/">https://fastlane.tools/</a> is a suite of open source automation tools backed by serious engineers. Here is what Fastlane gives us:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HLkl8NWw6y_1wFOf_oj9Jg.png" /></figure><p>They offer integration with all the major CI systems, so we don’t need to worry about that quite yet.</p><p><strong>—</strong></p><p>Cool, I think we are in a good spot to move on from mobile. For now this is what our mobile stack basically looks like (GCP Firebase vs AWS services):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*BvEPoPLWk8mjXzUtQwEJog.png" /></figure><h4>Conclusion</h4><p>This wraps up part one. In the coming parts we will cover aspects of our REP that include: infrastructure, platform, APIs, data (streaming/persistent/memory/warehouse) pipelines, Continuous Integration, web apps for retail, and how everything ties together.</p><p>If all looks good I’ll actually code a lot of this up &amp; open source it. Reach out if you’re interested in collaboration.</p><p><a href="https://twitter.com/rambossa"><em>follow me</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68d9dbe78102" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DIY Prisma, Fast Style Transfer app — with CoreML and TensorFlow]]></title>
            <link>https://medium.com/hackernoon/diy-prisma-fast-style-transfer-app-with-coreml-and-tensorflow-817c3b90dacd?source=rss-e17553b8e2c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/817c3b90dacd</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[coreml]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Ramos]]></dc:creator>
            <pubDate>Sat, 13 Jan 2018 20:28:39 GMT</pubDate>
            <atom:updated>2022-05-16T12:30:20.266Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3pT4W5JZphTdJtEzpXZtDQ.jpeg" /></figure><p><em>Create an iOS app — like Prisma — with CoreML, Fast Style Transfer, and TensorFlow.</em></p><h4>Table Of Contents:</h4><ul><li>Intro &amp; Setup</li><li>Preliminary Steps</li><li>CoreML Conversion</li><li>iOS App</li></ul><h3>Intro</h3><p>The basis of this tutorial comes from <a href="https://blog.prismalabs.ai/diy-prisma-app-with-coreml-6b4994cc99e1">Prisma Lab’s blog</a> and their PyTorch approach. However, we will use TensorFlow for the models and specifically, <a href="https://github.com/lengstrom/fast-style-transfer">Fast Style Transfer</a> by Logan Engstrom — which is a <a href="https://medium.mybridge.co/30-amazing-machine-learning-projects-for-the-past-year-v-2018-b853b8621ac7">MyBridge Top 30 (#7)</a>.</p><p>The result of this tutorial will be an <a href="https://hackernoon.com/tagged/ios">iOS</a> app that can run the TensorFlow models with CoreML. <a href="https://github.com/mdramos/fast-style-transfer-coreml"><strong>Here is the GitHub repo</strong></a><strong> </strong>— this also contains all adjustments and additions to fst &amp; tf-coreml.</p><p>What made this possible?</p><ul><li><a href="http://cs.stanford.edu/people/jcjohns/eccv16/">Standford Research</a></li><li><a href="https://github.com/lengstrom/fast-style-transfer">Fast Style Transfer</a></li><li><a href="https://developer.apple.com/documentation/coreml">Apple’s CoreML</a> <em>*Does not support TensorFlow</em></li><li><a href="https://www.tensorflow.org/mobile/tflite/">Google releases TensorFlow Lite</a> <em>*Does not support CoreML</em></li><li><a href="https://developers.googleblog.com/2017/12/announcing-core-ml-support.html">Google releases CoreML support</a> <em>*Does not offer full support</em></li><li>we make some adjustments and hack together a solution</li></ul><h3>Setup</h3><p><strong>Models:</strong> We’re going to use fst’s pre-trained models — custom models will work as well (you’ll need to make minor adjustments that I’ll note). <a href="https://drive.google.com/drive/folders/0B9jhaT37ydSyRk9UX0wwX3BpMzQ?usp=sharing">Download the pre-trained models.</a></p><p><strong>Fast Style Transfer: </strong><a href="https://github.com/lengstrom/fast-style-transfer">https://github.com/lengstrom/fast-style-transfer</a> <em>*clone and run setup if needed</em></p><p><strong>TensorFlow: </strong>With fst, I’ve had the most success using TensorFlow 1.0.0 , and with tf-corml you’ll need 1.1.0 or greater <em>*does not need to use GPU for this tutorial</em></p><p><strong>TensorFlow CoreML:</strong> <a href="https://github.com/tf-coreml/tf-coreml">https://github.com/tf-coreml/tf-coreml</a> <em>*install instructions</em></p><p><strong>iOS: </strong>11<strong><br>Xcode: </strong>9<br><strong>Python:</strong> 2.7</p><h3>Preliminary Steps</h3><p>We need to do some preliminary steps due to Fast-Style-Transfer being more of a research implementation vs. made for reuse &amp; production (no naming convention or output graph).</p><p><strong>Step 1:</strong> The first step is to figure out the name of the output node for our graph; TensorFlow auto-generates this when not explicitly set. We can get it by printing the net in the evaluate.py script.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80b75beb0d0fc89143f78ce684596845/href">https://medium.com/media/80b75beb0d0fc89143f78ce684596845/href</a></iframe><p>After that we can run the script to see the printed output. I’m using the pre-trained model <em>wave</em> here. <em>*If you’re using custom models, the checkpoint parameter just needs to be the directory where your meta and input files exist.</em></p><pre>$ python evaluate.py --checkpoint wave.ckpt --in-path inputs/ --out-path outputs/ </pre><pre>&gt; Tensor(“add_37:0”, shape=(20, 720, 884, 3), dtype=float32, device=/device:GPU:0)</pre><p>The only data that matters here is the output node name, which is <strong>add_37</strong>. This makes sense as the last unnamed operator in the net is addition, <a href="https://github.com/lengstrom/fast-style-transfer/blob/master/src/transform.py#L17">see here</a>.</p><p><strong>Step 2:</strong> We need to make a few more additions to evaluate.py so that we can save the graph to disk. Note that if you’re using your own models that you’ll need to add the code to satisfy the checkpoints directory condition vs. a single checkpoint file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a2d97f6ea4e64d9de8e71bec415d393/href">https://medium.com/media/4a2d97f6ea4e64d9de8e71bec415d393/href</a></iframe><p><strong>Step 3: </strong>Now we run evaluate.py on a model, and we will end up with our graph file saved. *<em>When training models we probably used a batch size greater than 1, as well as GPU, however CoreML only accepts graphs with an input-size of 1, and CPU optimizations — note the evaluate command to adjust.</em></p><pre>$ python evaluate.py --checkpoint wave/wave.ckpt --in-path inputs/ --out-path outputs/ --device “/cpu:0” --batch-size 1</pre><p>Awesome, this creates output_graph.pb &amp; we can move on to the CoreML conversion.</p><h3>CoreML Conversion</h3><p>Thanks to <a href="https://hackernoon.com/tagged/google">google</a>, there is now a TensorFlow to CoreML convertor: <a href="https://github.com/tf-coreml/tf-coreml">https://github.com/tf-coreml/tf-coreml</a>. This is awesome, but the implementation is new and lacking some core tf operations, like <em>power.</em></p><p><strong>Step 1:</strong> Our model will not convert without adding support for <em>power, </em>but luckily Apple’s <a href="https://apple.github.io/coremltools/generated/coremltools.models.neural_network.html?highlight=add_unary#coremltools.models.neural_network.NeuralNetworkBuilder.add_unary">coremltools provides a unary conversion</a> which supports power. We need to add this code into the TensorFlow’s implementation. Below is a gist for 3 files you will need to additions to.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01711a09456e4879d1af99f2a09234d6/href">https://medium.com/media/01711a09456e4879d1af99f2a09234d6/href</a></iframe><p><strong>Step 2:</strong> create and run the conversion script</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96132e492e184800bd82359bdd231015/href">https://medium.com/media/96132e492e184800bd82359bdd231015/href</a></iframe><pre>$ python convert.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*_Ezdp_IRuhVOq8LfFXedHQ.png" /></figure><p>The actual CoreML converter does not provide the capability to output images from a model. Images are represented by NumPy arrays (multi-dimensional arrays) — which are the actual output and compiled to a non-standard type of MultiArray in Swift. I searched for help online and was able to get some code that evaluated a graph outputted by CoreML and then traverse it to transform the output types to images.</p><p><strong>Step 3: </strong>Create and run the output transform script on the model (my_model.mlmodel) which was outputted above.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/32c31f3d8300ad30031fb8978ddf7dc1/href">https://medium.com/media/32c31f3d8300ad30031fb8978ddf7dc1/href</a></iframe><pre>$ python output.py</pre><p>and ….. 🎉💥🤙 ….. we have a working CoreML model. *<em>I changed the name of it to “wave” in the output script, also the image size corresponds to the input for evaluation.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*9fpbWBb_nUYnZirf077H8A.png" /></figure><h3>iOS App</h3><p>This isn’t so much an iOS tutorial, so you’ll want to work with my repo. I’ll only cover the important details here.</p><p><strong>Step 1: </strong>Import the models into your Xcode project. Make sure you add them to target.</p><p><strong>Step 2:</strong> After importing, you’ll be able to instantiate the models like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01f06e76456294384972a66ef8194f89/href">https://medium.com/media/01f06e76456294384972a66ef8194f89/href</a></iframe><p><strong>Step 3:</strong> Create a class for model input parameter, which is an MLFeatureProvider. <em>*img_placeholder is the input that is defined in the evaluate script</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/951081728c6fd5a06f6df3fd8af15945/href">https://medium.com/media/951081728c6fd5a06f6df3fd8af15945/href</a></iframe><p><strong>Step 4:</strong> Now we can call the model in our code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/89a9ecedd5e1957fcbf7741f60cfd556/href">https://medium.com/media/89a9ecedd5e1957fcbf7741f60cfd556/href</a></iframe><p><strong>Final:</strong> The rest of the app is just setup and image processing. Nothing new or directly related to CoreML, so we won’t cover it here. At this point, you’ll have a good understanding of how everything came together and should be able to innovate further. I think there can be improvement on fst’s graph. We should be able to gut out over-engineered operations to make the style-transfer even faster on iOS. But for now everything works pretty well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*cFnS6dqFLGlVwHXybpbXMg.png" /></figure><p>✌️🤙</p><blockquote><a href="https://twitter.com/backnotprop">follow me</a></blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=817c3b90dacd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/diy-prisma-fast-style-transfer-app-with-coreml-and-tensorflow-817c3b90dacd">DIY Prisma, Fast Style Transfer app — with CoreML and TensorFlow</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design Thoughts: Blockchain for Healthcare]]></title>
            <link>https://medium.com/hackernoon/developing-blockchain-for-healthcare-primer-d23004de7aed?source=rss-e17553b8e2c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/d23004de7aed</guid>
            <category><![CDATA[healthcare]]></category>
            <category><![CDATA[healthcare-technology]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Ramos]]></dc:creator>
            <pubDate>Thu, 21 Dec 2017 22:57:58 GMT</pubDate>
            <atom:updated>2019-09-04T16:18:35.238Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Gcbg9Ti3lhdGrUaBHVl6A.png" /></figure><p><em>Developing Blockchain for Healthcare, primer and introduction. This is more of an opinion-piece (it lacks formal citing).</em></p><h4>Primer, Table of Contents:</h4><p>- Intro<br>- Why does the Healthcare Industry need something like <a href="https://hackernoon.com/tagged/blockchain">Blockchain</a>?<br>- What would the solution look like?<br>- How should it be developed technically?<br>- What would I focus on developing?</p><h3><strong>Intro</strong></h3><p>I’ll be exploring &amp; developing “Blockchain For Healthcare.” This first part serves as a primer, and introduction exploring why the industry needs healthcare, and how developmental efforts should work.</p><p>I actually only got started on this path around 3 months ago. I was sent an invite to a <a href="https://medstro.com/groups/quadruple-impact-challenge/pages/home">Healthcare innovation contest</a>, where six finalists end up pitching-off in Vegas for a $10k prize. I made it to that round, but I didn’t win. Healthcare was never a passion of mine, but I was passionate about the competition (probably for wrong reasons that are out of context here). The point is that I wasn’t prepared to deliver any compelling idea that an insanely complicated industry, such as Healthcare, would consider. It wasn’t until my flight to Vegas, when I was thoroughly reviewing &amp; creating a strategy for my pitch, that I realized how unprepared I was. My submitted presentation offered nothing new beyond already defined buzzwords and a naive solution. Unlike the cryptocurrency environment, I wasn’t going to create considerable hype with a cool slide-deck or demo. I’ve learned a lot though, and think a possible blockchain solution for healthcare would be beneficial for people and the industry.</p><p>For those interested — here is my (now outdated) <a href="https://medstro.com/posts/8013">entry</a>, <a href="https://drive.google.com/file/d/18gNiDGi9z4jAYkCrg0rLEDe4eOXijgPO/view?usp=sharing">pitch deck</a>, <a href="https://drive.google.com/file/d/0ByIZZYtS9lQmRjVpRGUtS05Tc2RTaThxTzlzYU9OVlZuTjU0/view?usp=sharing">infographic</a>, and a <a href="http://mdramos.github.io/demo-deck">digital-demo</a> that is NOT mobile responsive &amp; runs best in Chrome.</p><h3><strong>Why does the Healthcare industry need something like Blockchain?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*vRK-PL4ulaVKJDIcFwPlXQ.jpeg" /></figure><p>Data in Healthcare is F’d. I’ll start with a notable example: Some critically-ill people carry around thick binders full of their diagnosis, medications, testings, research, insurance, genetics… literally every aspect of their health profile, everywhere they go. They spend hours researching, emailing, and creating networks with anyone who has the potential to help. They do this because the industry is failing them by not providing a means to efficiently store, share, or analyze their data in a globally unified way.</p><p>A buzzword you will often hear is “Siloed Data.” Patient’s data is manually on-boarded and placed into whichever <a href="https://en.wikipedia.org/wiki/Electronic_health_record">Electronic Health Record</a> their providers or health-networks are using. These are typically enterprise solutions that house most of the data collected. A lot of complexity can develop within organizations around their systems and the data collected:</p><ol><li>The larger the network or organization, the more likely that patient data is sparsed out by different departments and locations</li><li>Data formats are challenging (a ton of old data is still on paper, departments like radiology use images ro even sounds, same data can exist in different systems and even in different formats &amp; datatypes)</li><li>EHRs offer consistency, though data is not consistent and can be very complicated. Providers will opt for convenient methods for data collection that don’t always translate into easy system-processing</li></ol><p>Providers may handle these, plus many more issues, just fine. However, they end up building castles around their data which leads us into our next buzzword: “Interoperability.”</p><p>Data is rarely shared easily between different providers, networks, and EHRs. There are 1000+ EHRs in the United States; with that, EHRs are built without a standard business model. They weren’t built to talk/work with each other, and unfortunately doing so isn’t something that comes quick or cheap. The industry lacks effective standardization that has resulted in too many data-formats/types (<a href="http://hitconsultant.net/2014/04/28/in-depth-a-guide-to-healthcare-data-formats/">here is an article</a> with some insight, though it’s a bit outdated &amp; missing some newer formats). Integrating varying data-formats with different systems isn’t an easy task. Ask any healthcare developer; I’m sure you’ll hear horror stories such as single-columned data fields, like <em>birth-date</em>, which can create hell for someone working on an ETL process. Here is an awesome <a href="https://www.healthcatalyst.com/">HealthCatalyst</a> infographic that visualizes some of healthcare’s data problems:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*BlLJruIhCUF1HnwuItTxpQ.png" /></figure><p>Without efficient sharing of data, patients are missing out on essential studies, trials, and analysis. While Drug makers pay hundreds of thousands to hospitals to try and track down patients for clinical studies, patients might be desperately searching at will and without much avail. Why shouldn’t this be a more natural process for patients, and why can’t they benefit both medically, and monetarily without much effort? Patients aren’t in control of their digital data stores. Patient portals govern the digital accounting for patients (with or without their approval). While your credit data is compiled and analyzed into your credit score that follows you everywhere you go, your health data is disarranged and improperly managed.</p><p><a href="https://en.wikipedia.org/wiki/Enterprise_master_patient_index">Master Patient Indexes</a> and <a href="https://en.wikipedia.org/wiki/Health_information_exchange">Health Information Exchanges</a> are the closest things I’ve seen that address some problems of castled/siloed data. However, they face many of the same data-sharing challenges, and also aren’t immune to our last important buzzword, “security.” 4/5 physician’s offices have already suffered cyber attacks. More massive and centralized databases can leave us vulnerable to breaches at the scale of the last Equifax hack. For those who like more official studies/claims, check out <a href="https://www.hipaajournal.com/">www.hipaajournal.com</a>. The site has many <a href="https://www.hipaajournal.com/study-reveals-cybersecurity-healthcare-not-taken-seriously-enough/">great articles</a> on how serious of an issue cybersecurity is in the industry.</p><p>Two beasts still remain when talking about issues with healthcare and data: insurance and regulation. It’s not that they don’t deserve a true spot in this blog, it’s just that the data issues outlined above are the real gut of the problems that blockchain can really start solving. Regulation is definitely an important part, and its clear that the issues above are something everyone wants solved, but government moves slow and sporadically. I think a solution to the problems above would be presented in Government forums and could actually drive legislation forward.</p><h3><strong>What would the solution look like?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*tOebj4rmE8j1rEJ8H576QQ.jpeg" /></figure><p>Yes, a “Holy Grail” (full of beer) — At least this is what some are calling blockchain for healthcare. And theoretically, they’re not crazy. If you need a primer on blockchain, here are some brief starters:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F6WG7D47tGb0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D6WG7D47tGb0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F6WG7D47tGb0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9536763152ad2bffe67342a97c44d9e/href">https://medium.com/media/d9536763152ad2bffe67342a97c44d9e/href</a></iframe><ul><li><a href="https://en.wikipedia.org/wiki/Blockchain">Blockchain - Wikipedia</a></li><li><a href="https://anders.com/blockchain/">Blockchain Demo</a></li></ul><p>I can’t effectively explain blockchain in this blog without it going overboard — So, if you’re truly interested in the development of blockchain for healthcare then you will need to make sure you understand it along with concepts such as <a href="https://blockgeeks.com/guides/smart-contracts/">“Smart Contracts.”</a> We can move on from here by stating that these technologies offers a consistent, immutable, decentralized, and rule-based solution for the problems described above. Every transaction, or transfer-of-knowledge, is recorded on a distributed ledger that must be computationally &amp; mathematically verified by the blockchain itself. Combining blockchain with a method to store encrypted data could result in something truly worthwhile.</p><p>So how could it work for healthcare?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*affSWHqGxWR10AxhzG0x3Q.png" /><figcaption><strong>© </strong>Datastructr</figcaption></figure><p>As you can see, a user in this system would have complete control over their healthcare profile. They dictate who can read and what access another individual may have to their data. Obviously, a primary care physician would want to know as much as possible (and to also add to a person’s health profile), but individuals such as employers or family members might only need to know limited information. Users could walk into any doctors office, emergency room, physical therapist, etc. and immediately be on-boarded into the local system. The user could potentially offer parts of their profile to be queried by interested third-parties, such as researchers or pharmaceuticals. At a global scale, data becomes more reliable and available. Third-parties could formulate big-data analysis, or even provide potential trials to users. It’s not that these things aren’t already happening, but that blockchain offers an efficient, cheaper, and drastically simpler process.</p><p>Insurance would have to become a player in this system as well. Currently, health insurance is bloated. Many people pay for coverage they don’t need. A user in the blockchain system could benefit from a smart contract application which analyzes and uses a model to create a cheaper, but more appropriate, coverage plan. This type of application could disrupt the entire health-insurance industry in an unexpected way, though I believe it would be in the best way for users.</p><p>The above is just an example of how it could look for a single particular user. The “Holy Grail” aspect of it is the same picture applied to everyone, and for all of healthcare data existing in a single ecosystem that is democratically operated. New applications, models for business, insurance, policy, and big data analysis can all come to thrive on the blockchain. It is a system in which every player, especially the patient, may benefit.</p><h3><strong>How should it be developed?</strong></h3><p>Should there be a new cryptocurrency/<a href="https://en.wikipedia.org/wiki/Initial_coin_offering">ICO</a>? Should this be made with enterprise <a href="https://hackernoon.com/tagged/technology">technology</a>? Or open-source tech? Or how about a combination of all these things?</p><p>In my opinion, a new cryptocurrency/ICO is the wrong approach to solving the problems outlined. A new coin would need to incorporate extensive smart-contract and other blockchain-based capabilities (ledger, consensus, membership, transactional proofs, etc.). At the point where someone has developed such a thing, then they have built something grander, but more generic than a healthcare-specific solution. They would have created an entire platform and new cryptocurrency, similar to <a href="https://www.coinbase.com/what-is-ethereum?locale=en-US">Ethereum</a> (which currently has a market cap around $70B). A healthcare-specific coin with those capabilities doesn’t make much sense, and would be hard to take seriously if it weren&#39;t otherwise marketing itself as a platform — blockchain can be thought of in a similar sense as the principles of a car-engine, which is generic enough to be used in all sorts of automobiles. A car maker doesn&#39;t drastically change or redevelop the car engine, but rather the parts &amp; body around the engine that make the car unique. A new coin, centered around healthcare, can be developed on existing platforms, and some already are. They market heavily for their ICOs…but so do “<a href="https://mcfly.aero/">Flying Car Coins</a>.” You would need to question the actual motivation of someone trying to develop a currency for niche data-transactions, and how far they could actually take that for the industry.</p><p>This doesn&#39;t mean that blockchain economics wouldn&#39;t play a role in a healthcare solution. I believe that proven smart-contract based currencies/platforms, such as Ethereum, would play a significant part in the financial dealings of a healthcare blockchain, but not the underlying structure.</p><p>I believe that the development of underlying blockchain infrastructure is a large enough problem that a one-off team would have trouble creating a considerable solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bFJjXW6bcF9La5nt92aVZg.png" /></figure><p>Anyone developing a blockchain solution would be wise to take advantage of what is already available vs. developing a “unique” approach. Capable technologies are actively developed &amp; open-sourced by the enterprise and alike. My favorites are <a href="https://www.hyperledger.org/members">Linux Foundation’s</a> <a href="https://www.ibm.com/blockchain/hyperledger.html"><strong>Hyperledger</strong></a>, Microsofts’s <a href="https://azure.microsoft.com/en-us/blog/announcing-microsoft-s-coco-framework-for-enterprise-blockchain-networks/"><strong>Coco</strong></a>, and <a href="https://gem.co/gemos/"><strong>GemO</strong></a><strong>S</strong>. If you spend any time investigating those technologies, you’ll see that all of them are offering “<a href="https://en.wikipedia.org/wiki/Collaborative_software_development_model">open</a>” solutions. GemOS started as a healthcare-specific platform years ago. They’ve already experienced many pain-points and have sufficient knowledge of how blockchain can work in healthcare. Their platform has apis, integrations with tech such as Hyperledger &amp; Ethereum, and have developed ETL processes that developers could utilize for initial data collection (granted they can establish partnerships with EHRs/health-networks/existing business)... Any new development on these efforts would basically be recreating the wheel.</p><p>One big concern will be data at rest. Obviously most data will need to be encrypted and stored in a decentralized way. Smart contracts could possibly be the single-enabler in this fashion. <a href="https://blog.ethereum.org/2016/01/15/privacy-on-the-blockchain/">From the Ethereum blog</a>:</p><blockquote>We create an obfuscated smart contract which contains a private key, and accepts instructions encrypted with the corresponding public key. The contract stores account balances in storage encrypted, and if the contract wants to read the storage it decrypts it internally, and if the contract wants to write to storage it encrypts the desired result before writing it. If someone wants to read a balance of their account, then they encode that request as a transaction, and simulate it on their own machine; the obfuscated smart contract code will check the signature on the transaction to see if that user is entitled to read the balance, and if they are entitled to read the balance it will return the decrypted balance; otherwise the code will return an error, and the user has no way of extracting the information.</blockquote><p>Or a technology specifically made for decentralized storage could be utilized. Smart Contracts will still play an important role in as encryption key holders, but something like <a href="https://en.wikipedia.org/wiki/InterPlanetary_File_System">IPFS</a> could house and share encrypted data.</p><p>These open-source projects and platform offerings are perfect to bootstrap a “backend” for what would then be a patient-centric developmental effort.</p><h3><strong>What am I focused on developing?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*xug5SrBLlXIHcha_j1hcWA.jpeg" /></figure><p>Enterprise, &amp; even B2B, solutions are beginning to hit the market and are the focus of big dawgs like IBM, Accenture, Deloitte, Microsoft, +20 more huge firms. The industry moves slow though, and not always in the right direction for patients. This to me means there is major value-potential to be unlocked.</p><p>Since most of the hardcore blockchain work is provided to developers, then that would leave us with creating a solution for patients to willingly and actively utilize — This is the most significant challenge in my opinion. Questions like “Who is paying for it all?”, “Why would the enterprise (Health-Networks, EHRs) want to adopt or integrate?” wouldn’t matter because the patient would govern usage and participation by holding the key to their data.</p><p>Any solution that is adopted by a mass user base could end up disrupting the entire enterprise and healthcare landscape without their input. To do this patients &amp; their data must be won over in non-standard ways. I realized that my initial idea of creating a data exchange platform was too naive. This also seems to be the approach that others are taking (along with their own ICO…):</p><ul><li><a href="https://www.minthealth.io/">minthealth</a></li><li><a href="https://lacunadigital.com/home">Home</a></li></ul><p>While these applications seem rational, the reality is that they will most likely fail at getting users to engage or participate in a meaningful way. They seem to lack a genuine experience and empathy for users. I believe that a data-exchange could positively thrive in blockchain, but not a specifically focused one in which the user sells aspects their life on a transactional market. Whoever enjoyed <a href="https://en.wikipedia.org/wiki/Paid_survey">paid survey</a> sites, anyway?</p><p>My focus is abstracting away any transactional market, and providing an experience that builds trust and engages participation. Patient focus &amp; empathy will always be the most important driving factor, but I think the healthcare focus needs to also be abstracted in order to win over a large user base. Terms like “patient”, “data”, “healthcare” are non-starters for me and any solution I want to develop… but they will definitely come to play a part.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*dhR0mfvhIEGcoQxRvV-jHg.png" /></figure><p>My team is Datastructr, and we’ve worked (with collab of others) on this idea together. Reach out if you would also like to collaborate in anyway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ex7NEpTJm5TmTUH2GxD3zg.jpeg" /><figcaption>Dallas and I at the competition</figcaption></figure><p><em>Thanks to Josh Stein, Dallas Nix, and </em><a href="https://twitter.com/JT_0021"><em>JT</em></a><em> for their provided edits</em></p><p><a href="https://twitter.com/backnotprop"><em>follow me</em></a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d23004de7aed" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/developing-blockchain-for-healthcare-primer-d23004de7aed">Design Thoughts: Blockchain for Healthcare</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TensorFlow (GPU) Setup for Developers]]></title>
            <link>https://medium.com/hackernoon/tensorflow-gpu-setup-for-developers-7371ec0f04de?source=rss-e17553b8e2c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/7371ec0f04de</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[gpu]]></category>
            <dc:creator><![CDATA[Ramos]]></dc:creator>
            <pubDate>Tue, 31 Oct 2017 02:04:06 GMT</pubDate>
            <atom:updated>2019-05-13T11:49:35.702Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*Pgd8qomkwTZG_PbBuzxFaQ.png" /><figcaption>tensorflow, machine learning, gpu, setup-guide</figcaption></figure><h3>Intro</h3><p>…For devs wanting to run some cool models or experiments with TensorFlow (on GPU for more intense training). This probably isn’t for the professional data scientists or anyone creating actual models — I imagine their setups are a bit more verbose.</p><p>This blog post will cover my manual implementation of setting up/building TensorFlow with <a href="https://hackernoon.com/tagged/gpu">GPU</a> support. I’ve spent decent time reading posts and going through walkthroughs… and learned a ton from them… so I pieced together this installation guide to which I’ve been routinely using since (should have a CloudFormation script soon). There are obviously simple installs via pip/conda, but we want to manually build out TF and get it running on GPU… still this installation guide is for simple/default configurations and settings.</p><p>The Core (we will cover these as we go along):</p><ul><li>AWS EC2 p2.xlarge</li><li>Ubuntu 16.04</li><li>CUDA 8.0 (along with CUDDN)</li><li>TensorFlow 1.0</li><li>Python 2.x and libs (libs not directly needed here, but I base my installations around Python usage)</li></ul><h3>Launch your AWS EC2 Instance</h3><ol><li>Choose OS type: <strong>Ubuntu Server 16.04</strong></li><li>Choose Instance Type: GPU Compute &gt;<strong> p2.xlarge</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GiHn1PtaqZjAwHFO5b4hAg.png" /></figure><p>Why p2? They were made specifically for what we want to do, which is to run intense computations on the GPU. p2.xlarge offers us 12gb GPU. We will be able to do (batched) computationally-intensive <a href="https://hackernoon.com/tagged/learning">learning</a> just fine on this machine</p><p><strong>WARNING:</strong> p2 instances, while running, are <strong>$0.90/hour</strong> — So I suggest you only keep the instance state running while you are performing tasks such as training.</p><p>3) Configuration: Basic configurations are fine, you will need to use a VPC (default VPC and subnet settings are fine as well)</p><p>4) Storage: <strong>Note: </strong>when adding storage, account for the amount of data you’ll most likely be training on. For example, the COCO 2014 dataset (images) is around 15GB, and the trained neural net most commonly used for COCO is .5GB. Also, we will be downloading 100s of MBs of individual software and libraries. I’ve opted for <strong>50GB storage</strong> in my work, and have been using around 30–40GB of that.</p><p>5) Continue on, and setup with your preferences or the defaults. There is no other special settings that are needed to proceed, so launch and wait for the instance to be started.</p><p>Launch the instance, wait for it to be <em>running</em>, and we should be good to move on.</p><h3>Installation Guide</h3><p>SSH into your newly launched instance.</p><h4>Ubuntu updates</h4><pre>$ sudo apt-get update<br>$ sudo apt-get upgrade</pre><blockquote><strong>Note:</strong> If you get the response:</blockquote><blockquote>“new version of boot/grub/menu.lst …”</blockquote><blockquote>— I keep the local version in my testing environments. For production use, due diligence is required.</blockquote><h4>Dependencies</h4><p>useful tools we will need:</p><pre>$ sudo apt-get -y git vim curl build-essential cmake pkg-config zip</pre><p>this is also where I install the python libraries I will use (not required for tensorflow install):</p><pre>$ sudo apt-get -y install python-pip python-dev python-numpy python-scipy ipython python-matplotlib python-sklearn python-wheel</pre><p>other system libraries i’ve found to be required when building and using tensorflow:</p><pre>$ sudo apt-get -y install -y libpng12-dev ibjasper-dev libfreetype6 libjpeg-dev libtiff5-dev libgtk2.0-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev swig</pre><p>now create a directory for us to work out of:</p><pre>$ mkdir install &amp;&amp; cd install</pre><h4>Building TensorFlow</h4><p>We are going to be building TensorFlow from source. There is a simple pip installation, but we will get <em>better performance </em>— in some use cases — by building</p><p><a href="https://www.tensorflow.org/performance/performance_guide#build_and_install_from_source">https://www.tensorflow.org/performance/performance_guide#build_and_install_from_source</a></p><p>Bazel is TenorFlow’s build tool. Bazel needs to use our ip and because we are in a VPC, we need to change the hosts file.</p><p>To <strong>get your private ip-address</strong>, run <em>ifconfig </em>in the terminal… you’ll get an output, so look for <em>inet adds </em>and note that ip — (also available in the AWS Console)</p><ol><li>modify /etc/hosts:</li></ol><pre>$ sudo vim /etc/hosts<br>// [vim opens the file …]<br>## change this line:<br>127.0.0.1 localhost<br>## to (if your private ip is 155.10.100.10)<br>127.0.0.1 ip-155–10–100–10</pre><p>2. install Java (needed for Bazel):</p><pre>$ sudo add-apt-repository ppa:webupd8team/java<br>// [press enter]<br>$ sudo apt-get update<br>$ sudo apt-get install -y oracle-java8-installer<br>// [accept terms]</pre><p>3. install Bazel (0.5.1):</p><pre>$ wget <a href="https://github.com/bazelbuild/bazel/releases/download/0.5.1/bazel-0.5.1-installer-linux-x86_64.sh">https://github.com/bazelbuild/bazel/releases/download/0.5.1/bazel-0.5.1-installer-linux-x86_64.sh</a></pre><pre>$ chmod +x bazel-0.5.1-installer-linux-x86_64.sh<br>$ ./bazel-0.5.1-installer-linux-x86_64.sh</pre><p>Bazel will now be installed. Let’s add it in .bashr</p><p>modify ~/.bashrc (add the 2 lines to the end of the file):</p><pre>$ vim ~/.bashrc<br>// [vim opens the file]</pre><pre># Add to end of file:<br># BAZEL<br>source /home/ubuntu/.bazel/bin/bazel-complete.bash<br>export PATH=”$PATH:$HOME/bin”</pre><p>let’s load .bashrc into our shell now:</p><pre>$ source ~/.bashrc</pre><p>We now have Bazel.</p><p>Ok, before we get TensorFlow and build, we need to install our dependencies for GPU-support. These include CUDA and CUDNN. <br>For more info on these: <a href="https://en.wikipedia.org/wiki/CUDA">https://en.wikipedia.org/wiki/CUDA</a></p><p>install CUDA:</p><pre>$ wget <a href="http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_8.0.44-1_amd64.deb">http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_8.0.44-1_amd64.deb</a></pre><pre>$ sudo dpkg -i cuda-repo-ubuntu1404_8.0.44–1_amd64.deb<br>$ sudo apt-get -y update<br>$ sudo apt-get -y upgrade<br>$ sudo apt-get install -y cuda</pre><pre>// [will take a couple of minutes]</pre><pre>$ sudo sh -c “sudo echo ‘/usr/local/cuda/lib64’ &gt; /etc/ld.so.conf.d/cuda.conf”<br>$ sudo ldconfig</pre><p>To test that we have this installed correctly, run a simple command:</p><pre>$ nvidia-smi</pre><pre>## note, using:<br>## watch -n 0.5 nvidia-smi<br>## is a useful way to launch a “live” monitor of GPU stats, use this when you train your models</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*V-j2HMcC7NI3hWAmlDJm9Q.png" /></figure><p><strong>Note:</strong> For CUDNN, you will need a Nvidia developer account. You can get this here: <a href="https://developer.nvidia.com/rdp/cudnn-download">https://developer.nvidia.com/rdp/cudnn-download</a></p><p>After you have setup your account, go ahead and <strong>download the <em>8.0-linux-x64-v5.1</em> tarball to your own machine.</strong></p><p>We will transfer this file (and all others coming from our machine) to our EC2 instance using <em>scp.</em></p><p><strong>Note:</strong> Before you scp the cudnn tarball, edit the command below with your ec2 and correct paths</p><p>run <a href="https://en.wikipedia.org/wiki/Secure_copy">scp</a> command from your own machine (replace ip):</p><pre>$ scp -i \<br>     ~/keys/learner-key.pem \<br>     ~/Downloads/cudnn-8.0-linux-x64-v5.1.tgz \<br>     ubuntu@ec2–34–203–215–27.compute-1.amazonaws.com:~/install/</pre><pre>## the syntax:<br>## scp -i &lt;path_to_ec2_private_key&gt; &lt;path_to_file_to_transfer&gt; &lt;receiving_machine_and_path_to_dest&gt;</pre><p>After the tarball transfers, unzip and place:</p><pre>$ tar -zxf cudnn-8.0-linux-x64-v5.1.tgz<br>$ sudo cp -P cuda/lib64/* /usr/local/cuda/lib64/</pre><p><strong><em>TENSOR TIME</em></strong></p><p>Yea.. cool. Let’s go and get TensorFlow. Using v1 here.</p><pre>$ git clone <a href="https://github.com/tensorflow/tensorflow">https://github.com/tensorflow/tensorflow</a><br>$ cd tensorflow<br>$ git checkout v1.0.0</pre><pre>$ ./configure</pre><pre>// [launches configuration]</pre><p>This will launch the configuration script.</p><p><strong>Note:</strong> You will need to configure one setting as non-default: CUDA usage. So [press enter] to get all default settings, until you see the question asking if you want to support CUDA. <strong>YES </strong>we do. The following CUDA settings can be default as well.</p><p>Ok, TensorFlow is configured and ready to build. The build process is timely. Usually lasting around 1-hour on p2.xlarge. So to combat this, and not leave your process bound to the open shell, we will use <em>screen. Screen</em> is a tool that will allow us to launch a new window in the shell, start a process, and then <em>detach </em>from that window… and eventually allow us to come back/re-attach to that window/process. See more here: <a href="https://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/">https://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/</a></p><p>(screen also comes in handy when training your models and running those respective processes)</p><p>launch a new screen window:</p><pre>$ screen</pre><p>We should still be in the install/tensorflow directory</p><p>build TensorFlow with Bazel:</p><pre>$ bazel build -c opt — config=cuda //tensorflow/tools/pip_package:build_pip_package</pre><pre>// [bazel builds tensorflow here — long process]</pre><p><strong>Note: </strong>This is a long process, expect this to take an hour. Thanks to screen, we can detach from this window (close the ssh connection if you’d like) and take a break</p><p>To detach from the screen window where Bazel is building:</p><pre>ctrl-a + d</pre><p>… time period of tensorflow building …</p><p>After this break, reattach to the screen window that is building/built TensorFlow:</p><pre>$ screen -r</pre><p>install the new build using pip:</p><pre>$ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg</pre><pre>$ sudo pip install /tmp/tensorflow_pkg/tensorflow-1.0.0-cp27-cp27mu-linux_x86_64.whl</pre><p>We want to now make sure TensorFlow can find cuda before running. We need to add it into our environment.</p><p>modify ~/.bashrc</p><pre>$ vim ~/.bashrc<br>// [vim opens the file]</pre><pre># Add to end of file:<br># CUDA<br>export LD_LIBRARY_PATH=”$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64&quot;</pre><pre>export CUDA_HOME=/usr/local/cuda</pre><p>cd out to the home directory (make sure you are out of tensflow directory)</p><p>and</p><h3>TENSORFLOW IS INSTALLED!</h3><p>let’s test this in interactive Python:</p><pre>$ python<br>// [python interpreter opens]</pre><pre>&gt;&gt;&gt;<br>&gt;&gt;&gt; import tensorflow as tf</pre><pre>I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally<br>I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally</pre><pre>… more like output like this (good sign that we see CUDA)</pre><pre><br>## TEST SCRIPT:</pre><pre>&gt;&gt;&gt; with tf.Session() as sess:</pre><pre>…… sess.run(tf.global_variables_initializer())</pre><pre>…… print sess.run(output)</pre><pre>……</pre><pre>[press enter]</pre><pre>// [script runs — you will see an initial output]</pre><p>and to confirm we are using GPU, look for this output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EwjwaYKNJ3X8yjyX0hlhKA.png" /></figure><p><strong><em>Now go do some cool s***.</em></strong></p><p><a href="https://twitter.com/rambossa">follow me</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7371ec0f04de" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/tensorflow-gpu-setup-for-developers-7371ec0f04de">TensorFlow (GPU) Setup for Developers</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stable Matching Algorithm and How it’s Used]]></title>
            <link>https://ra-mos.medium.com/stable-matching-algorithm-and-how-its-used-913058fbbfcd?source=rss-e17553b8e2c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/913058fbbfcd</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[stable-matching]]></category>
            <category><![CDATA[matchmaking]]></category>
            <dc:creator><![CDATA[Ramos]]></dc:creator>
            <pubDate>Fri, 27 Oct 2017 17:41:58 GMT</pubDate>
            <atom:updated>2019-09-17T13:11:47.290Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y4JORkBaNk-wIkNOztxRSQ.jpeg" /><figcaption>The State Department used this algorithm for business network matching in the Americas</figcaption></figure><p><a href="https://backnotprop.github.io/stable-matching/"><em>Simple demo</em></a><em> , </em><a href="https://github.com/backnotprop/stable-matching"><em>repo</em></a><em> , </em><a href="http://www.dcs.gla.ac.uk/~pat/jchoco/roommates/papers/Comp_sdarticle.pdf">credit</a></p><p><strong>**this blog is in-progress: my implementation has covered many edge-cases, really focuses on an iterative/re-building approach (which the original algorithm does not account for), and the JS code relies on Immutable.js. I will need to restructure the blog a bit to account for those changes. The open-source code is also lacking what I’ve used in production.</strong></p><ol><li>Intro</li><li>Algorithm in-depth</li><li>Code</li></ol><h3>Intro</h3><p>We have a problem here: Match a single network of users with custom &amp; calculated match-preferences on each other in that network. Find a <em>stable</em> match for everyone</p><p><em>You want to build match.com?</em> — <strong>no</strong>, but yea sort of — there is a similar “Stable Marriage” problem, but this isn’t it because we are matching within the same network.</p><p>This is a familiar problem in matchmaking, and its well defined:<br><a href="https://en.wikipedia.org/wiki/Stable_roommates_problem"><strong><em>The Stable Roommate Problem.</em></strong></a></p><p>What is stability? In a given instance of the stable-roommates problem (SRP), each of <em>2n</em> participants ranks the others in strict order of preference. A matching is a set of <em>n</em> disjoint pairs of participants. A matching <em>M</em> in an instance of SRP is stable if there are no two participants <em>x</em> and <em>y</em>, each of whom prefers the other to their partner in <em>M</em>. Such a pair is said to block <em>M</em>, or to be a blocking pair with respect to <em>M.</em></p><p>Great, seems simple enough… But it’s not because humans are unique and we all have different wants/needs. The most simple example of an issue is a <em>love-triangle…</em> now imagine a love triangle enhanced to a 1000-person conflict… In production, and at scale, we don’t ever have a stable match. So we fail and quit? — no, we use the algorithm as a base and iteratively build/re-build until we can create the highest % of matching satisfaction. We finalize by trying to find a solution for those who are totally not matched as they would like.</p><p>How do we fully understand the problem and solution? Well, Im no a math wiz and deciphering white-papers filled with hieroglyphics isn&#39;t always fun, but Robert Irving’s work is well described so we start there, and then hammer out Google and YouTube:</p><p><a href="http://www.dcs.gla.ac.uk/~pat/jchoco/roommates/papers/Comp_sdarticle.pdf">An Efficient Algorithm for the “Stable Roommates” Problem</a> — Robert W Irving</p><p><a href="https://www.youtube.com/watch?v=5QLxAp8mRKo">Nice YouTube intro</a></p><h3>Understanding 3 stages of the solution-algorithm</h3><ol><li><strong>Proposal Stage</strong></li></ol><p>The first part of the algorithm involves everyone making proposals (proposers) to who they would like to be matched with (proposees). A proposal ends up either being rejected or accepted. On a first-come-first-serve basis, if a proposer is found their proposee’s preference list, then the proposal is accepted. If a proposer submits to a proposee who has already accepted another proposal, or if they are not preferred, then the proposal is rejected. The rejected proposer then tries again with their next preference. This continues on until everyone has an accepted proposal. There is a loop to which this works towards completion:</p><pre>// pseudocode<br>while: persons in the set are not matched<br>	person[i] is lowest index in set without a match<br>	person[i] makes match proposal to highest availible preference person[j], who has not already rejected person[i]<br>	if: person[j] has not accepted any other offer<br>		person[j] accepts person[i]<br>	else:<br>		if: person[j] preferes person[i] over previous acceptance of person[k]<br>			person[j] accepts person[i]<br>			person[k] rejects person[j]<br>		else:<br>			person[j] rejects person[i]<br>		end<br>	end<br>end</pre><p>After stage 1, no 1–1 perfect matches have been recognized yet (though they may exist). We now have a good baseline for possible matches. Also in this phase there can be a case where one person was rejected by all others. This creates instability. These rejects are thrown into a separate pool, and the algorithm continues. It is up to you how you want to handle outright rejections, but we use an iterative/rebuilding process to try and rematch them (but only after creating our initial sets of successful matches).</p><p><strong>2. Rejection of lesser Preferences</strong></p><p>At the start of stage 2, each person will have accepted a proposal from another, but at that time may still have other persons ranked lower in their list of preferences. This step is simple as we will just reject all combinations of that person and their lower ranked preference. This is possible because we know the person has already accepted an offer from another, and in the _worst_ case can be matched with them.</p><pre>for all accepted proposals between two people (person[i] &amp; person[j]):<br>	reject person[j] and person[k] where person[j] prefers person[i] over person[k]<br>end</pre><p>To make sense of the pseudocode, think of it like this: Alice has accepted a proposal from Bob, Charlie and Ada are listed after Bob in Alice’s ranking and Alice removes them since she is happy with Bob. But can’t Bob find better preference in someone else? — No, because he made the initial proposal to Alice, and step 1 would’ve ensured that there was no one, higher than Alice, who would’ve accepted his proposal.</p><p><strong>3. Cyclic Reduction</strong></p><p>The above step rejects proposals that fall under another accepted proposal with higher preference. It is really just a simple reduction phase, but can leave the matchings incomplete because we have not yet taken into account all higher ranking preferences that remain in each persons preference list. It is very well possible, and most likely, that the first and second phases in the algorithm did not optimize the matches so that everyone has the highest possible preferred match. This final step of the algorithm is meant to fix for that, or fail and declare that there can be no stable matching. Irving declares this as an <em>all-or-nothing-cycle</em>. The videos I’ve watched do a great job at explaining how this next phase works, but I really could not find a great explanation as to why it works. I even asked a <a href="http://programmers.stackexchange.com/questions/325755/why-does-the-last-phase-of-irvings-stable-roommates-matching-work">StackExchange question</a> explaining what I understood and if I could get a better concrete explanation. Hopefully upon the time of you reading this there has been an answer. If not, well, lets continue on anyway and implement the code which we understand fine.</p><p>This stage starts with any person’s, this case person1&#39;s remaining preference list and selects their <strong>second</strong> remaining preference person1List[2]. Use person1List[2]&#39;s (person2) own list (person2List) and select their <strong>last</strong> remaining preference person2List[L] (someperson3). We use these 2 selections as our starting pair (person1List[2],person2List[L]). With person2List[L] we will repeat the above process (by selecting person2List[L]’s second preference, and that persons last preference) and continue until we have once again rotated around back to our original pair of (`person1List[2],person2List[L]). At that point we will reject all <em>diagonal</em> pairs (personIList[2],previous personJList[L]). The <em>rotation/reject-diagonal-pairs</em> repeats until everyone has a single match or until it is declared that not everyone can be matched.</p><pre>for all rotations in (p1...pn) and (q1...qn)<br>such that rotation qi is second preference of pi and pi+1 is last preference of qi<br>do:<br>    for i = 1...n -1 DO:<br>    	reject(qi,pi+1)<br>    end<br>end</pre><h3>Initial Code and Test</h3><p>The code we will write and run will be JavaScript and run with Node.js</p><p>The data structure that we’ll be using is a simple javascript object that binds into a graph network/structure.</p><p>To generate dummy data we’ll use <a href="https://www.mockaroo.com/">Mockaroo</a>. That data can be found here: &lt;coming soon&gt; Now need to structure the data in a way that easy to use within our algorithm. See the function we use to parse the data here: &lt;coming soon&gt; and the output should look something like this:</p><pre><em>// parsing output</em> <br>{ <br>    1: { <br>        name: Alice, <br>        choices: [ {id: 2, strength: 3}, {id: 4, strength: 5} ] <br>    }, <br>    2:{ <br>        name: Bob, <br>        choices: [ {id: 4, strength: 6}, {id: 1, strength: 3} ] <br>    }, <br>    <em>// …</em> <br>}</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c3176c7ea990d5586e1173eb0796ce1/href">https://medium.com/media/8c3176c7ea990d5586e1173eb0796ce1/href</a></iframe><p>That is the initial structure in which we will work with. Since we have are pseudocode done, we can begin translating that to the JavaScript we want. The proposal stage is going to be a recursive function in which it tries to match everyone:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9fa46be3eed74f91b5519051a6f291d1/href">https://medium.com/media/9fa46be3eed74f91b5519051a6f291d1/href</a></iframe><p>We take in iteration as a parameter because we need a way to <em>reset</em> the mechanism for checking who a person has already sent offers to during the particular iteration of the recursive function (things may change during each iteration, i.e. a previously rejected offer may now accept). proposalProcess is called for each person in every iteration. It needs the sender of a proposal, receiver, and how the sender ranks the person being sent. The code follows the pseudocode and it looks like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0afd477e664770a24cba32fabaa3a21b/href">https://medium.com/media/0afd477e664770a24cba32fabaa3a21b/href</a></iframe><p>There we call the simple methods acceptOffer and rejectOffer:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/83bf9585a592812412ed4e142b404434/href">https://medium.com/media/83bf9585a592812412ed4e142b404434/href</a></iframe><p>eliminatChoices is a shared method the stages will use to eliminate persons from each others preference lists.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/64ee8787570c7873b6d79d2a8cef0b8e/href">https://medium.com/media/64ee8787570c7873b6d79d2a8cef0b8e/href</a></iframe><p>And thats it for stage one. There is the edge case though where a person(s) may end up having their offer rejected by everyone. Irving calls this <strong>unstable</strong> and will cause an infinite loop with our recursive function. We will need to use a work-around and as stated before we will most likely just remove that person from the current pool. For now though we can continue on and continue testing (our db and the preference list is randomized on every new run of the code — sometimes it may be unstable, but most times it will be fine).</p><p>Stage 2 is super simple. We just reduce everyone’s preference list and remove everyone ranked below the current accepted received proposal.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2cab44a23d7cb14933862e817f088bae/href">https://medium.com/media/2cab44a23d7cb14933862e817f088bae/href</a></iframe><p>part three notes here (sorry, will get to it soon)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a085152fb666cd34942cd6350b115f44/href">https://medium.com/media/a085152fb666cd34942cd6350b115f44/href</a></iframe><p><a href="https://twitter.com/backnotprop">follow me</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=913058fbbfcd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>