<?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 Yann Dupis on Medium]]></title>
        <description><![CDATA[Stories by Yann Dupis on Medium]]></description>
        <link>https://medium.com/@yanndupis?source=rss-acd60cda4b6f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TDT9gmnzfDS0Cn_63JpH4w.png</url>
            <title>Stories by Yann Dupis on Medium</title>
            <link>https://medium.com/@yanndupis?source=rss-acd60cda4b6f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 18:17:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yanndupis/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[Cape Python: Apply Privacy-Enhancing Techniques to Protect Sensitive Data in Pandas and Spark]]></title>
            <link>https://medium.com/dropoutlabs/cape-python-apply-privacy-enhancing-techniques-to-protect-sensitive-data-in-pandas-and-spark-e0bf8c0d55db?source=rss-acd60cda4b6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0bf8c0d55db</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[pandas]]></category>
            <dc:creator><![CDATA[Yann Dupis]]></dc:creator>
            <pubDate>Fri, 31 Jul 2020 11:44:14 GMT</pubDate>
            <atom:updated>2020-07-31T13:48:57.920Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VA-eQGO3NkEHeKT1FeXegA.png" /></figure><p>We’re extremely excited to have recently released the <a href="https://github.com/capeprivacy/cape-python">Cape Python</a> library. This library is one of the first building blocks to make your data science and machine learning pipelines privacy-preserving. As data scientists and data engineers, too often we unfortunately stumble on personally identifiable information (PII) that wasn’t necessarily relevant for our project. Other times, we needed access to a dataset, but it took months to obtain. Compliance teams pointed out a lack of transparency regarding how the sensitive data would be protected, how it would be used, and who would have access. For obvious ethical reasons, and increasing regulations such as GDPR, it’s becoming critical for data teams to make privacy a top priority when working on data science and machine learning projects. However, there is clearly a lack of accessible tools integrated with the current data science ecosystem to make it possible.</p><p><a href="https://github.com/capeprivacy/cape-python">Cape Python</a> offers several masking techniques to help you obfuscate sensitive data involved in internal data science and machine learning projects. We consider these techniques to be a first step in your privacy journey. We tried to make them as simple as possible so you can quickly start experimenting and thinking about how to make your projects more privacy-preserving. We built this library with the following objectives in mind:</p><ul><li><strong>Accessible:</strong> these techniques should be very easy to understand and apply at scale with popular data science libraries, such as Pandas and Spark.</li><li><strong>Collaborative:</strong> data science, machine learning, governance and security teams should be able to collaborate effectively to define and edit data privacy policy through human-readable policy files.</li><li><strong>Transparent: </strong>At any point, it should be possible to validate which privacy techniques have been applied to which dataset for which task.</li></ul><p>In the rest of the blog post, we will introduce these masking techniques and give you some guidance to select the right technique depending on your use case. We will walk you through a concrete example where we will experiment with several techniques in Pandas, then define a data privacy policy, and finally apply this policy in a Spark pipeline. You can find the code associated with the blog <a href="https://github.com/capeprivacy/cape-python/tree/master/examples/tutorials/credit">here</a>.</p><h3>What are Cape Python’s masking techniques?</h3><p>Cape Python offers several masking techniques to obfuscate identifiers (<a href="https://en.wikipedia.org/wiki/De-identification#:~:text=De-identification%20is%20the%20process,the%20privacy%20of%20research%20participants.">de-identification process)</a> and sensitive information, included in the dataset. The appropriate method to use depends on the data type (string, numeric, date, etc.), the accuracy you need to maintain, and the type of identifiers:</p><ul><li><strong>Direct identifiers:</strong> information that relates specifically to an individual. For example: name, address, social security number, etc.</li><li><strong>Indirect identifiers / quasi identifiers:</strong> Information that can be combined with other information to potentially identify a specific individual. For example: city, zip code, income, etc. As a concrete example, <a href="http://latanyasweeney.org/work/identifiability.html">Latanya Sweeney’s work</a> demonstrated that “87% of the U.S. population are uniquely identified by date of birth, gender and zip code”.</li></ul><p>Here is the preliminary list of techniques:</p><p><strong>Tokenizer:</strong> this maps each value to a token. If a value is repeated several times across the field, it always gets mapped to the same token in order to maintain the count. Typically, you would apply the tokenizer to a string field such as name.</p><p><strong>Perturbation: </strong>add noise to numeric and date fields. This transformation gives you the ability to tune the amount of noise you’d like to add. For example, add a random value between -5 and 5 to the age field. If it’s a date, you can specify the amount of noise for each frequency (e.g, day, hour, minutes, etc.).</p><p><strong>Rounding: </strong>reduce the precision of a numeric field by rounding it to the given number of digits. For example, you could decide to reduce the precision of the salary fields, or latitude/longitude field.</p><p><strong>Redaction: </strong>delete certains rows or columns. You could decide, for example, to drop the street name and zip code fields from the dataset because it’s irrelevant to the task.</p><p>With these four simple techniques, you can already mask your sensitive data for data science tasks. However, we’d like to bring to your attention that although these techniques allow you to reduce individual privacy leakage, they don’t guarantee protection against all potential privacy attacks.</p><h3>Pseudonymization is not enough to release data to untrusted audience</h3><p>In 2006, Netflix launched a machine learning competition which consisted of predicting users’ ratings based on a set of previous ratings. Before publishing the dataset publicly, they carefully removed all the user information and perturbed several records (by minimally modifying rating dates, for example). Even though they took these precautions, in 2017 <a href="https://www.cs.utexas.edu/~shmat/shmat_oak08netflix.pdf">two researchers from The University of Texas at Austin demonstrated</a> it was possible to re-identify individuals by leveraging the IMDB dataset as an external source of knowledge (this is known as a linkage attack).</p><p>The process of applying masking techniques to remove direct identifiers is called <a href="https://en.wikipedia.org/wiki/Pseudonymization">pseudonymization</a>. With Cape Python you can obfuscate the indirect identifiers by perturbing the values or reducing their precision. However, as demonstrated by the Netflix example, these techniques will not prevent all privacy attacks, such as linkage attacks.</p><p>For this reason, it’s important to use these techniques only in an environment where the assumption of a trusted data user is satisfied. For example, when a data scientist is working internally on a credit risk modeling or fraud detection project. However these techniques are not sufficient to release a dataset publicly, or share it with an untrusted external organization.</p><p>For data science use cases in public or untrusted settings, we plan to support differential privacy in a later release of Cape Python. Differential Privacy allows us to quantify the privacy leakage and offer stronger privacy guarantees. Here is <a href="https://www.microsoft.com/en-us/research/wp-content/uploads/2011/10/PID2016981.pdf">the definition</a> by <a href="https://en.wikipedia.org/wiki/Cynthia_Dwork">Cynthia Dwork</a>, who co-invented differential privacy: “Differential privacy describes a promise, made by a data curator to a data subject: you will not be affected, adversely or otherwise, by allowing your data to be used in any study, no matter what other studies, data sets, or information from other sources is available.”. As you can see, in the context of the Netflix example, this definition guarantees an attacker wouldn’t be able to re-identify individuals in the Netflix dataset even if they perform a linkage attack using the IMDB dataset.</p><p>Let’s dive into a concrete example of using Cape Python in a data science pipeline.</p><h3>Easily prototype your privacy-preserving pipeline in Pandas</h3><p>It’s extremely easy to start experimenting with these masking techniques using Pandas. Let’s say you are a team of data engineers and data scientists who are working on a credit modelling task for a bank. You know that there is a credit dataset you could use but it includes some sensitive information about the clients. As a team, you’d like to experiment with these masking techniques on a mock dataset similar to the credit dataset to figure out how to better preserve privacy.</p><p>As an example, we will experiment with the public <a href="https://archive.ics.uci.edu/ml/datasets/statlog+(german+credit+data)">German credit card dataset</a>. We just added some fake PII information (such as name, address, etc.) and quasi-identifiers to make it more similar to a real dataset for which we would use these techniques.</p><p>Voilà, a sample of the dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xfjht2AsvVGMhvpY" /></figure><p>Here are some questions you could ask yourself to figure out how to mask this dataset:</p><ul><li>Who can view this dataset?</li><li>What are the direct and quasi identifiers?</li><li>Is there sensitive data irrelevant for the task I could redact right away?</li><li>Could I re-identify a person using the quasi identifiers (city, salary, age, etc.) and additional sources of information?</li><li>How much utility from this sensitive data do I need to maintain for this task?</li></ul><p>One potential approach to protect the credit dataset could be to say that ‘name’ is irrelevant for the task, and therefore we should remove it. However, there’s another approach. We might want to count the number of unique people or clients in the dataset, or validate if there is one or several loans per client, and then validate the aggregation level of the dataset. For these reasons, you can apply the tokenizer, which will map each name to a unique token. Each name will be obfuscated, but the dataset will still maintain the correct user count.</p><p>The dataset also contains an individual’s address and city. If this location information is too granular or not useful for the task, we could simply remove these columns. Or, if we think the credit risk could vary based on the city, we could tokenize these fields instead. We won’t know the city name, however, we can still assess the predictive power of this variable if it is included in the model.</p><p>Do we need to know the exact age of the client? Or would having a general idea of their age be sufficient to assess credit risk? If the latter, we can perturb age by adding a random value within a certain range (e.g., [-5, 5]). (Just keep in mind the amount of noise could impact the utility/accuracy of your model).</p><p>Even though the application date is not a direct identifier, if we know that only one person applied on a certain day, we could re-identify this person. We could perturb these dates by adding or removing days (e.g., within [-3, 3]) to help reduce the ability to link this column with other information or datasets.</p><p>You could also tokenize the sex field. You probably don’t want to include this variable in your credit risk model. However, for fairness considerations, you should validate that people receive similar loan approval rates independent of their gender.</p><p>Finally, you can reduce the precision of salary, which could be considered sensitive information, by rounding it to the nearest 1000s. If you decide to include the debt ratio in your model, this transformation shouldn’t really impact the outcome of your model.</p><p>Let’s see how it looks in code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/39228c2ce9d63419a03759d014e8a6ae/href">https://medium.com/media/39228c2ce9d63419a03759d014e8a6ae/href</a></iframe><p>Once you applied these transformations, your dataset should like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VNwU3ENaatMGoYXQ" /></figure><p>When applying privacy techniques, it’s always important to keep in mind the trade-off between privacy and utility. Let’s assume that age is a strong predictor to identify good credit risk vs bad credit risk. By increasing the amount of noise, you reduce the risk of the potential privacy leakage; however, you would also lose some utility. As you can see in the example below, the age distributions without perturbation and with perturbation within the interval [-5, 5] tend to be similar. Higher risk individuals tend to be younger, with a spike in the mid-20s. However, if you add more noise with perturbation within the interval [-20, 20], the distribution starts to look very different from the original distribution. By adding too much noise, you might lose the predictability of this variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Vo_Gh7IC62Ak9JrS" /></figure><p>In the future, we are planning to introduce differential privacy techniques which will allow you to quantify the privacy loss depending on the amount of noise, and also provide strong theoretical guarantees.</p><h3>Bring transparency to your organization through policy-based interface</h3><p>As mentioned earlier, we believe transparency and collaboration are critical if we want to apply privacy techniques effectively. Once you have figured out which transformations you’d like to apply to the different fields, you can express the exact same transformations in a policy file. Here is a subset of the policy file (the entire policy can be found <a href="https://github.com/capeprivacy/cape-python/blob/master/examples/tutorials/credit/policy/credit_policy.yaml">here</a>):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2753d9263a160d3f16d70b8b75c4f179/href">https://medium.com/media/2753d9263a160d3f16d70b8b75c4f179/href</a></iframe><p>Once you have written your policy, it can be applied to your Pandas dataframe with only two lines of codes:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a52cd38042ce8229cc58d0663892f2d/href">https://medium.com/media/2a52cd38042ce8229cc58d0663892f2d/href</a></iframe><h3>Make your Spark pipeline privacy-preserving</h3><p>Finally, if you want to deploy these masking techniques at scale, you can apply this policy with the exact same two lines of code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6b8aa21865967c5cff6450e5ce5abe9b/href">https://medium.com/media/6b8aa21865967c5cff6450e5ce5abe9b/href</a></iframe><p>If needed, it’s also possible to apply the transformations to the Spark DataFrame with the programmatic approach we used earlier in Pandas. The transformation API is the same for Pandas and Spark.</p><h3>Next Steps</h3><p>Hopefully, this tutorial gave you a stronger idea about how and when you can apply privacy-preserving masking techniques, and how you can go from prototyping these techniques during exploratory analysis to applying these techniques transparently at scale.</p><p>We are planning to expand these techniques, and even give you the ability to create and contribute your own. We would love to hear your feedback and suggestions through our <a href="https://roadmap.capeprivacy.com/privacy/1-cape-privacy-portal">Product roadmap</a> or via <a href="https://github.com/capeprivacy/cape-python/issues">GitHub issues</a> for additional integrations (e.g., Beam, Dask, etc.) and privacy techniques that you would find useful. We also encourage contributions, so feel free to take a look at our open issues and chime in via our <a href="http://capecommunity.slack.com/">Slack community</a> if you’d like to get more involved!</p><p>In the coming weeks, we are planning to open-source additional Cape Privacy features, so stay tuned for future releases!</p><p>A big thank you goes out to <a href="https://twitter.com/kjam">Katharine Jarmul</a>, <a href="https://twitter.com/jvmncs?lang=en">Jason Mancuso</a>, <a href="https://twitter.com/mortendahlcs">Morten Dahl</a> and <a href="https://twitter.com/DragosRotaru">Dragos Rotaru </a>for help with this post!</p><h3>About Cape Privacy</h3><p><a href="https://capeprivacy.com/"><em>Cape Privacy</em></a><em> is an enterprise SaaS privacy platform for collaborative machine learning and data science. It helps companies maximize the value of their data by providing an easy-to-use collaboration layer on top of advanced privacy and security technology, helping enterprises increase the breadth of data included in machine learning models. </em><a href="https://capeprivacy.com/"><em>Cape Privacy</em></a><em>’s platform is flexible, adaptable, and open source. It helps build trust over time providing for seamless collaboration and compliance across an organization or multiple businesses. The company is based in New York City and is backed by boldstart ventures and Version One with participation from Haystack, Radical, and Faktory Ventures.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0bf8c0d55db" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dropoutlabs/cape-python-apply-privacy-enhancing-techniques-to-protect-sensitive-data-in-pandas-and-spark-e0bf8c0d55db">Cape Python: Apply Privacy-Enhancing Techniques to Protect Sensitive Data in Pandas and Spark</a> was originally published in <a href="https://medium.com/dropoutlabs">Cape Privacy (Formerly Dropout Labs)</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Encrypted Deep Learning Training and Predictions with TF Encrypted Keras]]></title>
            <link>https://medium.com/dropoutlabs/encrypted-deep-learning-training-and-predictions-with-tf-encrypted-keras-557193284f44?source=rss-acd60cda4b6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/557193284f44</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[cryptography]]></category>
            <dc:creator><![CDATA[Yann Dupis]]></dc:creator>
            <pubDate>Fri, 23 Aug 2019 13:22:52 GMT</pubDate>
            <atom:updated>2019-08-23T13:22:52.076Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jMduY9WijhYnV7u9RXR32g.jpeg" /></figure><p><a href="https://github.com/tf-encrypted/tf-encrypted">TF Encrypted</a> aims to make encrypted deep learning accessible. For this reason, we are pleased to share with the community that TF Encrypted now offers a high level API, <a href="https://github.com/tf-encrypted/tf-encrypted">TF Encrypted Keras</a>, which matches a subset of <a href="https://keras.io/">Keras</a>’s features. This is an important first step to supporting complex neural network architectures and use cases.</p><p>François Chollet, the creator of <a href="http://keras.io/">Keras</a>, aimed to provide the best user experience possible when designing the <a href="http://keras.io/">Keras</a> API. As he explained in <a href="https://blog.keras.io/user-experience-design-for-apis.html">this blog post</a>, good UX reduces cognitive load (e.g., remembering how things work). Therefore, users focus their energy on solving their actual problems. That’s what we love about Keras: the user is at the center.</p><p>Encryption adds an entirely new dimension, but with <a href="https://github.com/tf-encrypted/tf-encrypted">TF Encrypted Keras</a> we hope to still allow the users to focus on solving their problems. Our goal with <a href="https://github.com/tf-encrypted/tf-encrypted">TF Encrypted Keras</a> is to enable:</p><ul><li>Data Scientists to iterate quickly to build, for example, the best skin cancer detection model or fraud detection model on encrypted data.</li><li>Cryptographers to focus on creating the best encryption scheme without having to rebuild higher-level machine learning concepts.</li><li>Machine Learning researchers to run quick experiments to discover optimized architectures for encrypted deep learning.</li></ul><p>In the rest of the blog post we will show how you can train models and provide predictions on encrypted data. We will also share how <a href="https://github.com/tf-encrypted/tf-encrypted">TF Encrypted Keras</a> can integrate with other TensorFlow libraries such as <a href="https://github.com/tensorflow/privacy">TF Privacy</a> specialized in differential privacy.</p><h3><strong>Encrypted Training</strong></h3><p>As a data scientist or machine learning engineer, one of the biggest challenges is getting access to training data, especially when the data is sensitive. The data owner doesn’t want to be exposed to liability risks for sharing private, sensitive data. For example, a hospital may want to work with an AI startup to train a skin cancer detection model, but (understandably) refuses to share private patient data. These difficulties can also occur internally at a company. For example, two different bank entities might not be able to share their data to train a fraud detection model for legal reasons.</p><p>Imagine, instead, that the raw data is never shared with the data scientists. Only its encrypted form is shared. As we described in <a href="https://medium.com/dropoutlabs/secure-logistic-regression-mpc-vs-enclave-benchmark-65cf5f03a81f">an earlier blog post</a>, even though the data is encrypted with <a href="https://medium.com/dropoutlabs/secret-sharing-explained-acf092660d97">multi-party computation</a>, it’s still possible to perform computations on this encrypted data. This means that data scientists can train, predict, and validate his model without revealing the original data.</p><p>Encrypting this data prevents liability risks, which enables data scientists to get access to this sensitive data to train their models. That AI startup may be able to create that skin cancer detection model after all, and enable large scale access to medical expertise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rKD41md2TgXUxaC9" /><figcaption>Using TFE Keras, Data Scientists can train models on encrypted data</figcaption></figure><p>With <a href="https://github.com/tf-encrypted/tf-encrypted/tree/master/examples/notebooks/keras-training">TFE Keras</a>, it’s very easy to train your deep learning model. The code snippet below shows how you can train a simple logistic regression model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88d58daa59e78a286b4903b32a9e02d1/href">https://medium.com/media/88d58daa59e78a286b4903b32a9e02d1/href</a></iframe><p>You can define the model using the Sequential API. If you have used Keras before then, this will look very familiar. Once you compile the model with the right optimizer and loss, you can start training the model with the fit method. To experiment, you can run <a href="https://github.com/tf-encrypted/tf-encrypted/tree/master/examples/notebooks/keras-training">this notebook</a>.</p><h3><strong>Encrypted Predictions with Public Training</strong></h3><p>Encrypted deep learning also preserves user privacy when using machine learning services. For example, the user could take a photo of his skin lesions with his cell phone. The image will be sent in an encrypted form to the <a href="https://github.com/tf-encrypted/tf-encrypted">TF Encrypted</a> model. Finally, <a href="https://github.com/tf-encrypted/tf-encrypted">TF Encrypted</a> will perform a private prediction without having to decrypt the image during computation. We could imagine a similar approach to get a loan pre-approval from a bank.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j28vIXWsWxheQvIx" /><figcaption>Using TFE Keras, users only share encrypted data to get the prediction</figcaption></figure><p>In the code snippet below, we define a convolutional model with <a href="http://keras.io/">TF Keras</a> to perform an image classification.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7195fff8572426a769f24f9fc66ab64f/href">https://medium.com/media/7195fff8572426a769f24f9fc66ab64f/href</a></iframe><p>With the functions <em>tfe.keras.models.clone_model</em> you can easily transform a normal TF Keras model into a private <a href="https://github.com/tf-encrypted/tf-encrypted">TFE Keras</a> model. Your model is now ready to serve private predictions. This is very useful in a context where the data scientist is able to get access to the data, but wants to serve private predictions to preserve the privacy of his users.</p><p>If you prefer, you can also manually define the <a href="https://github.com/tf-encrypted/tf-encrypted">TFE Keras</a> model and set the weights from a numpy file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/102a4276fb4cce709ded7d6f2ce6b3a7/href">https://medium.com/media/102a4276fb4cce709ded7d6f2ce6b3a7/href</a></iframe><p>As you can see <a href="https://github.com/tf-encrypted/tf-encrypted">TFE Keras</a> matches a subset of <a href="http://keras.io/">TF Keras</a> API exactly.</p><p><a href="https://github.com/tf-encrypted/tf-encrypted/tree/master/examples/notebooks/keras-classification">Here</a> you can find a series of notebooks, showing in three steps how you can train a model, serve private predictions, and query the private model.</p><h3>Encrypted Predictions After Public Training with Differential Privacy</h3><p>Unfortunately, encrypted deep learning can’t always prevent privacy leaks. When the model is trained on raw data or encrypted data, it’s possible that the model memorized some sensitive information contained in the original training dataset. Once the model is deployed, adversaries could reveal this sensitive information by querying the model or inspecting the model weights. Two common attacks are <a href="https://www.cs.cornell.edu/~shmat/shmat_oak17.pdf">membership inference</a> and <a href="https://www.cs.cmu.edu/~mfredrik/papers/fjr2015ccs.pdf">model inversion</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tGuiVhmwwGm5gtXgJ9NO-A.png" /><figcaption>Differential Privacy prevents the model from memorizing sensitive data</figcaption></figure><p>The good news is that we can solve these problems with the library <a href="https://github.com/tensorflow/privacy">TF Privacy</a>, which is specialized in differential privacy. The library is extremely easy to use. To train the model, you just have to call their differential privacy optimizer (<a href="https://arxiv.org/pdf/1607.00133.pdf">DP-SGD</a>), which will prevent the model from memorizing sensitive data with specific privacy guarantee (<a href="https://en.wikipedia.org/wiki/Differential_privacy">epsilon</a>). We will focus a blog post or two on differential privacy in the future, but in the meantime, you can read these two excellent blog posts to learn more about differential privacy and how to use TF Privacy:</p><ul><li><a href="https://medium.com/tensorflow/introducing-tensorflow-privacy-learning-with-differential-privacy-for-training-data-b143c5e801b6">Introducing TensorFlow Privacy: Learning with Differential Privacy for Training Data</a></li><li><a href="http://www.cleverhans.io/privacy/2019/03/26/machine-learning-with-differential-privacy-in-tensorflow.html">Machine Learning with Differential Privacy in TensorFlow</a></li></ul><p>Once your model is trained with differential privacy, it’s extremely easy to transfer the weights to the TFE Keras model to start serving private predictions (since TFE Keras matches the TF Keras API). <a href="https://github.com/tf-encrypted/tf-encrypted/tree/master/examples/notebooks/keras-classification">Here</a> you will find a series of notebooks demonstrating how you can train your model with <a href="https://github.com/tensorflow/privacy">TF Privacy</a>, then serve private predictions with TFE Keras.</p><h3><strong>Next Steps</strong></h3><p>We hope these examples give you an idea of how you can apply encrypted deep learning, and demonstrate that you don’t have to be an expert in cryptography to start training and serving predictions on encrypted data. You can experiment with these new features in the <a href="https://github.com/tf-encrypted/tf-encrypted/blob/master/CHANGELOG.md#058">version 0.5.8</a> of <a href="https://github.com/tf-encrypted/tf-encrypted">TF Encrypted</a>.</p><p>The next steps for Encrypted Keras are:</p><ul><li>Expand the <a href="https://github.com/tf-encrypted/tf-encrypted">TFE Keras</a> API to train and serve more complex models and tackle new use cases such as NLP.</li><li>Adjust some implementation details to improve user experience.</li><li>Give the option to train the model with differential privacy on encrypted data.</li><li>Provide documentation and tutorials to run <a href="https://github.com/tf-encrypted/tf-encrypted">TFE Keras</a> in the cloud.</li></ul><p>As mentioned recently by Morten Dahl, “the motivation behind<a href="https://twitter.com/tf_encrypted"> @tf_encrypted</a> is simple enough to fit in a tweet”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z9uktqw_7xbb5QPu" /></figure><p>Please join the <a href="https://github.com/tf-encrypted/tf-encrypted">TF Encrypted </a>community on <a href="https://app.slack.com/client/TCFT10MFZ/">Slack </a>to contribute to democratizing encrypted deep learning!</p><h3><strong>About Dropout Labs</strong></h3><p><em>We’re a team of machine learning engineers, software engineers, and cryptographers spread across the </em>Uni<em>ted States, France, and Canada. We’re working on secure computation to enable training, validation, and prediction over encrypted data. </em><a href="https://medium.com/dropoutlabs/introducing-dropout-labs-d1b96f638ae2"><em>We see a near future where individuals and organizations will maintain control over their data, while still benefiting from cloud-based machine intelligence</em></a><em>.</em></p><p><em>Visit our </em><a href="https://dropoutlabs.com/"><em>website</em></a><em> or </em><a href="https://medium.com/dropoutlabs"><em>blog</em></a><em> or </em><a href="https://github.com/tf-encrypted/tf-encrypted"><em>TF Encrypted</em></a><em> repository for more information, or</em><a href="https://twitter.com/dropoutlabsai"><em> follow us on Twitter</em></a><em> for up-to-date announcements.</em></p><p><em>If you’re passionate about data privacy and AI, </em><a href="https://dropoutlabs.com/#contact"><em>we’d love to hear from you</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=557193284f44" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dropoutlabs/encrypted-deep-learning-training-and-predictions-with-tf-encrypted-keras-557193284f44">Encrypted Deep Learning Training and Predictions with TF Encrypted Keras</a> was originally published in <a href="https://medium.com/dropoutlabs">Cape Privacy (Formerly Dropout Labs)</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Path to Sub-Second, Encrypted Skin Cancer Detection]]></title>
            <link>https://medium.com/dropoutlabs/encrypted-skin-cancer-detection-3d096d3b7237?source=rss-acd60cda4b6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d096d3b7237</guid>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[healthcare]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-privacy]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Yann Dupis]]></dc:creator>
            <pubDate>Thu, 13 Jun 2019 17:58:44 GMT</pubDate>
            <atom:updated>2019-06-13T17:58:44.281Z</atom:updated>
            <content:encoded><![CDATA[<p><em>TL;DR: Using </em><a href="https://github.com/tf-encrypted/tf-encrypted"><em>TF Encrypted</em></a><em>, we were able to detect skin cancer on encrypted images. Within the last year, we reduced the runtime from 24 hours to 36 seconds. This work applies generally to privacy-preserving computer vision. The following post describes our journey to achieve this result and our roadmap to sub-second performance. You can find the code </em><a href="http://github.com/dropoutlabs/encrypted-skin-cancer-detection"><em>here</em></a><em>.</em></p><h4><strong>Democratizing AI in Healthcare While Maintaining Privacy</strong></h4><p>If there is an area where machine learning will soon significantly improve our lives, it’s healthcare. Researchers have made several breakthroughs in applications involving medical imaging over the past three years. Machine learning systems that leverage deep learning techniques are now capable of diagnosing <a href="https://ai.googleblog.com/2016/11/deep-learning-for-detection-of-diabetic.html">diabetic retinopathy</a><strong>, </strong><a href="https://cs.stanford.edu/people/esteva/nature/">skin cancer</a>, and <a href="https://arxiv.org/pdf/1903.08297.pdf">breast cancer</a>. As of 2016, more than 415 million diabetics worldwide were at risk of diabetic retinopathy (which is the fastest growing cause of blindness). Approximately <a href="https://www.aad.org/media/stats/conditions/skin-cancer">3,5 million people</a> in the U.S. are diagnosed with skin cancer every year. Over 232,000 women were diagnosed with breast cancer in the U.S. in 2015. Unfortunately, one of the biggest challenges is gaining access to specialists early enough to be treated effectively; this is particularly problematic in remote areas. Machine learning could democratize access to the best medical imaging diagnostics across the globe.</p><p>However, machine learning and privacy have traditionally been at odds. This creates a problem for data scientists building and deploying machine-learning-based healthcare systems as a service. Deep learning models need to have access to very large datasets to achieve state-of-the-art performance. Unfortunately, this data is often siloed among several organizations because of privacy concerns and liability risks. It is also very difficult to maintain control over personal data within these machine learning services. In short, in order to benefit from these powerful diagnostics, you have to share your data.</p><p>At Dropout Labs, we strongly believe that encrypted machine learning is the solution: enabling models to be trained and queried while the model, inputs, and outputs are encrypted. At no point is raw data shared or revealed.</p><h4><strong>Encrypted Deep Learning — a Technical Challenge</strong></h4><p>To build these encrypted deep learning systems, we use <a href="https://en.wikipedia.org/wiki/Secure_multi-party_computation">secure multi-party computation</a> (MPC), which is a subfield of cryptography. MPC brings multiple parties together to jointly compute a function while keeping the input and output private. The primitive that powers MPC is the ability to split a piece of data into multiple encoded parts, known as secret shares. On their own, the shares reveal nothing about the original data. However, if two parties perform the same operation on a set of shares and then recombine them, it is as if that operation was performed on the original data.</p><p>With MPC, you can easily add and multiply tensors. With these two basic operations you can begin building encrypted deep learning models. However, the challenge here is that MPC involves multiple parties (e.g., several servers), which introduces some networking overhead. MPC also requires large integers greater than 64 bits, which introduces some computational overhead as well. You can learn more about MPC in this <a href="https://medium.com/dropoutlabs/secret-sharing-explained-acf092660d97">blogpost</a>.</p><h4><strong>The Trials and Tribulations</strong></h4><p>In Spring 2018, we built our encrypted deep learning library from scratch in Go. We were excited to see if we could provide private predictions to detect skin cancer so we trained a convolutional model (similar to <a href="https://arxiv.org/pdf/1409.1556.pdf">VGG16</a>) on skin lesion images. Our secure computation protocol, called <a href="https://github.com/tf-encrypted/tf-encrypted/tree/master/tf_encrypted/protocol/pond">Pond</a>, didn’t support comparisons at that time, as it is a very expensive operation with MPC. So we replaced the Max-Pooling layer with an Average-Pooling layer, and the exact ReLU was approximated by a polynomial. We replaced the last three fully connected (FC) layers with a single smaller FC layer. We found that this had a negligible impact on model accuracy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AJsQyPXQxrhbjcb47YHQwA.png" /><figcaption>VGG16’s 1st block with approximated ReLU and Average-Pooling</figcaption></figure><p>The final VGG16 model included about 15 million parameters with an <a href="https://developers.google.com/machine-learning/crash-course/classification/roc-and-auc">AUC</a> of 0.89 on the testing set. Believe it or not, it took more than 24 hours to get a private prediction. Our implementation in Go was not optimized enough to compensate the networking and computation overhead mentioned previously. It became obvious improving this would require us to build a stack on top of existing libraries, which meant a significant investment and lead us consider another approach.</p><h4><strong>From 24 Hours to 8 Minutes in TensorFlow</strong></h4><p>In parallel, our colleague Morten was investigating if TensorFlow could be a good fit for MPC, and for secure computation more generally. After experimenting with a proof of concept, we quickly saw the performance gain by leveraging a modern <a href="https://en.wikipedia.org/wiki/Dataflow_programming">distributed computation</a> platform such as TensorFlow. The first time we tried to run a private prediction with the variant of VGG16 model, it took 8 minutes. It was just the beginning of a long series of performance improvements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OQc4RxJCOyanh2Sn2Sux0w.png" /><figcaption>Encrypted skin cancer detection runtime (seconds)</figcaption></figure><h4><strong>From 8 Minutes to 1 Minute 4 Seconds with SecureNN</strong></h4><p>Very quickly, we were able to decrease the runtime for this same model to around a minute. To achieve this result, we mainly cleaned up the code and re-used triples (masking tensors required by matrix multiplication in MPC). Throwing more CPUs at this problem also made a big difference. Tensorflow’s ability to parallelize computation and prioritize the right operation to save on networking drastically decreased the runtime. However, we discovered we were getting low accuracy for large models because of the approximated ReLUs.</p><p>The next step was to implement the <a href="https://medium.com/dropoutlabs/announcing-securenn-in-tf-encrypted-9c9c3e8a5a52">SecureNN protocol.</a> This protocol broke speed records for encrypted machine learning with MPC in 2018. One of the benefits of this protocol is that it supports comparison operations, so we could use a VGG16 model architecture out of the box with Max-Pooling and exact ReLU layer. We still replaced the last three fully-connected layers with a single small fully-connected layer (~15 million parameters).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AEUUqdIIIPjCW0D73_KYmQ.png" /><figcaption>VGG16’s 1st block with exact ReLU and Max-Pooling</figcaption></figure><p>This meant data scientists could leverage existing pre-trained models on <a href="http://www.image-net.org/">ImageNet</a>, then perform transfer learning to achieve better accuracy for their tasks. We were also able to make it work with int 64 tensors instead of very large integers. We ran our private predictions again and were able to achieve 1 minute 4 seconds with 96 vCPUs on each machine on GCP. Even though it was a bit slower than the POND protocol, by using <a href="https://eprint.iacr.org/2018/442.pdf">SecureNN</a> we maintained the model accuracy. It was a concrete example of the trade-off between performance and accuracy, which is part of the challenge when using encrypted machine learning.</p><h4><strong>55 Seconds with SecureNN</strong></h4><p>Seeding the triples enabled us to run this model in under a minute. We plan to cover this concept in greater detail in a future post, but the short and sweet is that you need a triple for every neuron in your model, and we were able to replace these millions of triples with a single seed that can generate the same set of numbers on each party. This greatly reduces the communication overhead.</p><h4><strong>36 Seconds with SecureNN, While Tweaking the Model.</strong></h4><p>In the previous sections, we described many secure computation optimizations. However, you can also play with different neural network architectures to better fit MPC constraints. By just replacing the Max-Pooling layer by an Average-Pooling layer, which involves only matrix multiplications instead of comparisons, you can query the model in 36 seconds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ThU2T5ULq60mhUU9lm8ykA.png" /><figcaption>VGG16’s 1st block with exact ReLU and Average-Pooling</figcaption></figure><h4><strong>The Path to Sub-Second</strong></h4><p>The open source library <a href="https://github.com/tf-encrypted/tf-encrypted">TF Encrypted</a>, built on top of TensorFlow, allowed us to easily run many experiments and scale large models. We look forward to experimenting over the next couple of months to potentially query this type of model in sub-seconds. Here are several potential avenues:</p><ul><li>Improve the polynomial approximation approach</li><li>Tweak neural network architectures</li><li>Quantization</li><li>Network pruning</li><li>Continue to integrate cutting-edge secure computation protocols and introduce engineering optimizations</li></ul><p>We will continue updating with our progress. In addition, we encourage you to experiment with <a href="https://github.com/tf-encrypted/tf-encrypted">TF Encrypted</a> to continue pushing the boundaries of this technology and we look forward to hearing your feedback about how we can make encrypted deep learning more accessible.</p><p>We truly hope encrypted deep learning can contribute to democratizing access to AI healthcare while maintaining privacy. Making encrypted deep learning faster will improve the diagnostic power of these models by enabling access to a gigantic source of siloed data. It will also help to provide diagnoses to more patients, at a lower cost and without compromising personal data.</p><p><em>A big thank you goes out to </em><a href="https://twitter.com/gavinuhma"><em>Gavin Uhma</em></a><em>, </em><a href="https://twitter.com/jvmancuso"><em>Jason Mancuso</em></a><em>, </em><a href="https://twitter.com/bendecoste"><em>Ben DeCoste</em></a><em>, </em><a href="https://twitter.com/ianlivingstone"><em>Ian Livingstone</em></a> and <a href="https://twitter.com/m__maclellan"><em>Matt MacLellan</em></a><a href="https://twitter.com/bendecoste"><em> </em></a><em>for help with this post!</em></p><p><strong>About Dropout Labs</strong></p><p>We’re a team of machine learning engineers, software engineers, and cryptographers spread across the Uni<em>ted States, France, and Canada. We’re working on secure computation to enable training, validation, and prediction over encrypted data. </em><a href="https://medium.com/dropoutlabs/introducing-dropout-labs-d1b96f638ae2"><em>We see a near future where individuals and organizations will maintain control over their data, while still benefiting from cloud-based machine intelligence</em></a><em>.</em></p><p>Visit our <a href="https://dropoutlabs.com/"><em>website</em></a><em> or </em><a href="https://medium.com/dropoutlabs"><em>blog</em></a><em> or </em><a href="https://github.com/tf-encrypted/tf-encrypted">TF Encrypted</a><em> repository for more information, or </em><a href="https://twitter.com/dropoutlabsai"><em>follow us on Twitter</em></a><em> for up-to-date announcements.</em></p><p><em>If you’re passionate about data privacy and AI, </em><a href="https://dropoutlabs.com/#contact"><em>we’d love to hear from you</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d096d3b7237" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dropoutlabs/encrypted-skin-cancer-detection-3d096d3b7237">A Path to Sub-Second, Encrypted Skin Cancer Detection</a> was originally published in <a href="https://medium.com/dropoutlabs">Cape Privacy (Formerly Dropout Labs)</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>