<?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 Christophe Pere on Medium]]></title>
        <description><![CDATA[Stories by Christophe Pere on Medium]]></description>
        <link>https://medium.com/@pere-christophe?source=rss-9cf1f3f55c40------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*feXx4uWsXrLVaRLoSzCUkg.jpeg</url>
            <title>Stories by Christophe Pere on Medium</title>
            <link>https://medium.com/@pere-christophe?source=rss-9cf1f3f55c40------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 01:44:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pere-christophe/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[Quantum Feature Importance Selection]]></title>
            <link>https://pere-christophe.medium.com/quantum-feature-importance-selection-1a5886d99d80?source=rss-9cf1f3f55c40------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a5886d99d80</guid>
            <category><![CDATA[quantum-algorithms]]></category>
            <category><![CDATA[aiq]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[qml]]></category>
            <dc:creator><![CDATA[Christophe Pere]]></dc:creator>
            <pubDate>Sun, 26 Mar 2023 19:14:26 GMT</pubDate>
            <atom:updated>2023-03-26T19:16:32.047Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*crmBmr5sXOkj44ZNzZY2fw.jpeg" /><figcaption>Copyright Pexel: <a href="https://www.pexels.com/@anna-nekrashevich/">Anna Nekrashevich</a></figcaption></figure><p>From Grossi et al., 2022, Fig. 5 [1]</p><h3>Introduction</h3><p>Recently I was reproducing the paper written by Grossi et al., 2022 about fraud detection. It was a fascinating problem because it was quantum oriented with a hybrid approach. It was a real-world application of a quantum algorithm.</p><p>The authors don’t provide the code or the data due to confidentiality (IBM project). There is no data or code, so the best challenge is developing new knowledge. The approach through the paper is simple, using undersampling to reduce the dataset’s size and balance it. Then classical methods are used as a baseline to benchmark a quantum support vector classifier (QSVC).</p><blockquote>This work was done at PinQ2 (<em>Plateforme d’innovation Quantique du Québec</em>). A special thanks to Sean Wagner, Alexandre Choquette from IBM quantum and Jérôme Schmaltz for their help and review during this project.</blockquote><h3>Aim</h3><p>The current state of quantum computing doesn’t allow using many features (columns) and samples. The hardware and the number of qubits limits us. The authors tackle the problem by using classical features’ importance extracted through different classical methods (XGBoost, GBT, RF). It’s also a standard way in quantum machine learning to reduce the size of the dataset. However, and I fully agree, the authors argue that classical features’ importance destroyed interesting information that a quantum algorithm can use.</p><p>The authors developed a quantum approach based on the features’ importance selection using a QSVC. They provide the schema of their system (Figure 5 of the paper). See below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*OWDxumkKSc0F6hlSrzg1lw.png" /><figcaption>Figure 5: Quantum Feature Importance Selection process, Grossi et al., 2022</figcaption></figure><p>The literature on quantum feature selection isn’t significantly developed, so I jumped on the challenge of reproducing the algorithm. As they described in the paper, only the kernel is computed on a quantum computer (or simulator).</p><h4>How to interpret the schema?</h4><p>Steps of the feature selection: <br>1 — initialization -&gt; select the 3 first features of the data <br>2 — run QSVC -&gt; with circuit runner or primitives <br>3 — evaluation with specific metrics (predict the test to evaluate the model)<br>4 — record KPI and feature ids <br>5 — if there is more feature, select other features in permutation without repetition <br>6 — start with the best set of features; add one feature<br>7 — repeat 2, 3, 4, 5 <br>8 — compare the KPI with one feature added to the KPI obtained with the previous number of features<br>9 — if there is no improvement, stop the algorithm and output the KPI and ids of the best features <br>10 — if improvement, repeat 6, 7, 8, 9, 10</p><p>Strictly speaking, you will evaluate many kernels in the process. Why?</p><p>The first step is about unique permutations of 3 features on the full features.</p><ul><li>7 features lead to 35 unique permutations</li><li>11 features lead to 165 unique permutations</li><li>33 features lead to 5456 unique permutations</li><li><strong>69</strong> features lead to <strong>52394</strong> unique permutations</li></ul><p>It was highly expensive. Don’t hope to run that on a real system. The KPIs are metrics to evaluate the kernel: precision, recall, accuracy… it’s up to you.</p><h3>Code implementation</h3><p>I will provide my implementation of the QFIS algorithm. I used <strong><em>Qiskit</em></strong> with <strong><em>IBMRuntime primitives </em></strong>and the local sampler of primitives to use simulators. I reproduced the 2 steps based on the description in the paper and Figure 5.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e4d5e2ccc76cd034029e33daaa7e9a6/href">https://medium.com/media/4e4d5e2ccc76cd034029e33daaa7e9a6/href</a></iframe><p>Three functions constitute the code above. The second is the execution function, where the kernel is transpiled into a circuit to be run on the backend with the different options. You can see the parameter env in the function declaration, meaning that the function can be used in your local machine when the parameter is set to local and in the cloud cloud parameter. The function uses two Sampler versions, one for the cloud and one for local.</p><p>The advantage of <strong><em>primitive</em></strong> is to use error mitigation. This method corrects the information in the qubit through the process to be more accurate. However, the problem is the waiting time with the IBMQ platform when you use the cloud option. Each session will be positioned in the queue, and even ibmq_qasm_simulator from the cloud, the computation can take hours rather than minutes with the local simulator.</p><h4>Run the function</h4><p>You split the data into train and test sets through each machine learning project. So what are the parameters?</p><ul><li><strong>X</strong> is the train set</li><li><strong>y</strong> is the array of labels of the train set</li><li><strong>X_test</strong> is the test set</li><li><strong>y_test</strong> is the array of labels of the test set</li><li><strong>backend</strong> is the backend where you want to run the algorithm (real system or simulator)</li><li><strong>options</strong> are parameters for runtime primitive</li><li><strong>service</strong> is mainly to load your account via runtime</li><li><strong>max_features</strong> is the maximum number of features you want to select (if none, the algorithm will try all the combinations until it doesn’t improve during permutations)</li><li><strong>n_reps</strong> is the number of repetitions for the ZZFeatureMap</li><li><strong>env</strong> to determine where to run the algorithm, local or cloud</li></ul><p>You just need these parameters to execute the function and wait until the process is done.</p><pre># simulator on local machine <br>_features_, results = quantum_feature_importance_local(X_ibm_train_qfis, y_ibm_train_qfis, X_ibm_test_qfis, y_ibm_test_qfis, backend=backend, <br>                               options=options, service=service, max_features=7)</pre><p>Here I specified 7 features as the maximum number of features. I ran the code on a local machine with the `<em>qasm_simulator</em>` from <strong>BasicAer</strong> module (<strong>Qiskit</strong>).</p><h4>Output</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zanrYUrPoRh2TOKxLk1STQ.png" /></figure><p>The QFIS algorithm output prints the best result for a combination. Here are used <strong>balanced accuracy</strong> and <strong>AUC</strong> as evaluation metrics. The model reaches 80% accuracy with the set (0, 1, 4). Adding a fourth feature didn’t improve this score, so the algorithm stopped.</p><h4>Cloud?</h4><p>The next code block will show you how to use the QFIS. You will define the service and options and backend.</p><pre>from qiskit_ibm_runtime import QiskitRuntimeService, Options<br><br># service <br>service = QiskitRuntimeService(channel=&quot;ibm_quantum&quot;, token=&quot;...&quot;) # put your token here<br><br># Options<br>options = Options(optimization_level=3)<br>options.resilience_level = 3 # 1<br>options.execution.shots = 8192<br><br># backend <br>backend = service.provider(&#39;ibmq_qasm_simulator&#39;)<br># simulator on local machine <br>_features_, results = quantum_feature_importance_local(X_train, y_train, X_test, y_test, backend=backend, <br>                               options=options, service=service, max_features=7, env=&#39;cloud&#39;)</pre><p>You can use all the providers you want through the backend parameter. It can be the qasm_simulator or real devices.</p><h3>Computation time evaluation</h3><p>I made many iterations with different backends, different sample sizes, and different numbers of features. In the backend section (Table below) is a real device, <strong><em>ibmq_montreal</em></strong>, a cloud simulator <strong><em>ibmq_qasm_simulator</em></strong>, and a local simulator, <strong><em>qasm_simulator</em></strong>. The interesting part is the training time for each test. The sets (11, 165), (33, 5490), (69, 52394) are computational estimated times (525600 minutes correspond to 1 year).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DwXMEti7zCFKgqzfauLN5w.png" /></figure><p>As you can see, using the QFIS on a local simulator is easier. The queue on the IBMQ platform can’t allow this type of approach.</p><h3>Conclusion</h3><p>Quantum feature importance or selection is critical for quantum algorithms. Using classical reduction methods, feature importance or feature selection can kill the performance or advantage of a quantum algorithm how the data will be selected or reduced needs to be adapted to the algorithm. Your preprocess must be quantum if you want to use a quantum algorithm.</p><p>Evaluating the importance of features with the quantum approach proposed in the paper requires an expensive computation time. To reduce this effect, a local quantum simulator helps iterate quickly. The final can be trained on a real device, but the selective process is better to run on a local machine with a GPU in single precision.</p><p>Another way, is to use the Session to run multi-kernel evaluations. The advantage is when the Session is open on real hardware, you have a time slot of 8 hours. So you can run multiple algorithms during this period.</p><h3>Reference</h3><p>[1] Grossi et al., 2022, Mixed Quantum-Classical Method For Fraud Detection with Quantum Feature Selection — <a href="https://arxiv.org/pdf/2208.07963.pdf">https://arxiv.org/pdf/2208.07963.pdf</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a5886d99d80" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deutsch-Jozsa, or How to Evaluate a Balanced Function]]></title>
            <link>https://pere-christophe.medium.com/deutsch-jozsa-or-how-to-evaluate-a-balanced-function-b19fe0711187?source=rss-9cf1f3f55c40------2</link>
            <guid isPermaLink="false">https://medium.com/p/b19fe0711187</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[qiskit]]></category>
            <category><![CDATA[deutsch-jozsa-algorithm]]></category>
            <dc:creator><![CDATA[Christophe Pere]]></dc:creator>
            <pubDate>Wed, 27 Jul 2022 14:52:57 GMT</pubDate>
            <atom:updated>2022-07-29T01:14:13.724Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aMVush6_yMDxOnaJ0AZ6jg.png" /><figcaption>Draw by the author</figcaption></figure><h4><em>The Hello World! of quantum advantage</em></h4><h3>Introduction</h3><p>Each technology or programming language has its version of a “Hello World!” program. With this “simple” program, you can start coding or using the technology. For example, in Python, the language we use in this book, the Hello World concept is to print a string like this: print(‘Hello World!’). This chapter uses the “Hello World!” approach to implement Deutsch-Jozsa’s (DJ) algorithm within a quantum computing language. The DJ algorithm is a mapping algorithm where we will know if a function is balanced (half 0s half 1s) or constant in one algorithm query. Our “Hello World!” is a little more complicated than just printing a string. Still, the DJ algorithm is an excellent start to understanding how quantum algorithms can be better than classical equivalents.</p><blockquote><a href="https://github.com/Christophe-pere/Deutsch_Jozsa_qiskit">The code of the article can be found on my GitHub.</a></blockquote><h3>The ‘black-box’ of the Boolean function</h3><p>Imagine you want to study a specific function’s behaviour. A function which can be constant or balanced. Constant means that the function only outputs the values of 0 or 1. Balanced refers to a behaviour where the output will be half 0 and a half 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aMVush6_yMDxOnaJ0AZ6jg.png" /><figcaption>A Quantum oracle considered a black box needed to be queried to determine the function’s behaviour. Draw by the author</figcaption></figure><p>Mathematically, you can formulate the problem as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*5-rXJTdpPb9kgMu-d_NDjg.png" /></figure><p>Sounds weird, doesn’t it? You will pass n bits with a value of 0 or 1 to the function to see if an output of 0 or 1 is obtained. The process of passing n bits to the function is called a query. The goal is to give information to understand the behaviour of the output, like a bandit slot machine where you put in money and hope to win. The device’s output is usually 0 (no cash) if you don’t execute enough queries. The probability dictates that the output will be zero for a finite number of inputs.</p><p>How many times do we query the function to obtain the result? By result, I mean a long chain of 0 and 1, but the probability of receiving 0 and 1 leads to the conclusion of “constant” or “balanced” behaviour. Start with the classical approach and the best case. You need only two queries. Why?</p><ul><li>In the first call, you pass the value 0 to the function and receive the value 0; it’s written like this: f(0) = 0</li><li>In the second call, you pass the value 1 to the function and receive the value 1; the corresponding mathematical equation is f(1) = 1</li></ul><p>Remember that the number of inputs is finite, so we will not query the function to infinity. Also, the results are statistical, meaning that you have an output probability of obtaining 0 or 1. Getting 1 once doesn’t mean that the function has an equal distribution.</p><p>The function is balanced; it’s the best case (f(1) = 0 and f(0) = 1). In the worst case? You will need to test half of the possibilities plus one. Remember, balanced means half of the function has the values 0s and the other 1s. So, you will need to test half of the input plus one. 2^n represents all the possibilities, so half of them are written 2^(n-1)and you need one more test so: 2^(n-1)+1tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KU2J2PeBYaCrkUZKBT3qJA.png" /><figcaption>Representation of half of the space in the worst classical case to test the balance of a finite input space to the classical function (oracle). Draw by the author.</figcaption></figure><p>Imagine you have a 4-bit string in input; this corresponds to 2⁴ possibilities (16). You will test 8 combinations plus one, so 9evaluations. In the same way, we can compute the probability that the function is balanced.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/1*_44zXjzhMVAulQeDxHsnIQ.png" /></figure><p>with 1 &lt; x &lt; 2^(n-1).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q4NJfZeXaUbxiFI0v19_lQ.png" /><figcaption>Evolution of the probabilities. Draw by the author.</figcaption></figure><p>The probability is a way to have a good idea of the behaviour; the more queries you do, the higher the probability that the function is constant.</p><p>The worst or best case has the same value with a quantum algorithm, like the Deutsch-Jozsa algorithm. You always need a unique query to find if the function is balanced or constant.</p><p>How is this possible? In a <a href="https://pere-christophe.medium.com/classical-versus-quantum-computing-cb04f8948d4b">previous post</a>, I mentioned that a quantum computer accesses some form of parallelism when using qubits. The quantum layer estimates all the possibilities at once. Deutsch Jozsa’s algorithm uses this property with a specific component called an <strong>oracle</strong>. An oracle is a <strong>black-box</strong> operation. The oracle will evaluate all possible input variations in one query to output an aggregate result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kKkbNLi8btPGKnHYaNBKcw.png" /><figcaption>Representation of an oracle for Deutsch Jozsa’s algorithm. Draw by the author.</figcaption></figure><p>Do you remember the Big O notation explained concisely in the <a href="https://pere-christophe.medium.com/classical-versus-quantum-computing-cb04f8948d4b">Classical vs quantum post</a>? Here, you have an <strong>exponential gain</strong> (quantum advantage). The classical approach needs 2^(n-1)+1calls against 1 for the quantum algorithm. The difference in time complexity is 2^nand it’s called exponential optimization.</p><h3>Did you say Oracle?</h3><p>Yes, like the sibyls of Rome, oracles were women who spoke in the name of Gods. They were considered to have been empowered by the Gods to provide their advice to mortal people.</p><blockquote><strong>Bra-Ket notation</strong><br>In quantum mechanics, the matrices transformation and vectors manipulation is done with the bra-ket notation (or Dirac notation) to represent quantum states.<br>A bra is a row in a matrix, and the symbol represents &lt;psi|. <br>Example: &lt;psi| = [2+3i , 5-4i , 2i] <br>A ket is a column in the matrix represented by |psi&gt;. <br>Example:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*YJK7uaRLSp8NHkHvL8XyoA.png" /></figure><blockquote>You can transform a bra into a ket and vice versa with the conjugate transpose.</blockquote><p>In the case of quantum algorithms, oracles are black-box operations. They provide not the voice of gods but an algorithm (like a classical function) as an input to another algorithm. Oracles are like masks with different properties that will help you simulate the physical effect you want to solve. An oracle will act on qubits to output a transformation. Most of the time, the formulation is written like this: O|x&gt; = |f(x)&gt; where <em>O</em> is the oracle and <em>x</em> a <strong>state vector</strong> of the qubits x = {x_0, x_1, ..., x_n} with <em>n</em> the number of inputs).</p><p>An oracle’s main advantage is allowing the user to focus on the quantum techniques to analyze the function rather than the function itself. But there is a significant drawback to the black-box. The output size can be different from the input size, which would break the reversibility rule. It’s essential to ensure that your oracle can be reversible.</p><p>What is an oracle in the context of Deutsch-Jozsa’s algorithm? In the constant case, the input is equal to the output. The transformation corresponds to a multiplication of the identity matrix and the input: input x I = output = input</p><p>On the other hand, in the balanced case, the oracle’s output will be half 0s and half 1s.</p><h3>Implementations of the Deutsch-Jozsa’s algorithm</h3><p>The code snippets will be provided for Qiskit. Qiskit isn’t the only open-source quantum library, but it’s one of the most used, and its community is huge.</p><p>For an introduction to Qiskit and how to install the different modules, please look at <a href="https://pere-christophe.medium.com/qiskit-new-modules-306c384503be">my post on Qiskit</a>.</p><h4>Corresponding classical pseudocode</h4><p>You probably have an idea of how to do the function’s evaluation in a classical code to determine if the function is constant or balanced. You can use simple if...else statements to assess the behaviour. The following simple pseudocode tested the function of the oracle and compared it with the output and so iteratively.</p><pre>if f(0) = 0:<br>    if f(1) == ):<br>        print(“The function is constant”)<br>    else:<br>        print(“The function is balanced”)<br>else:<br>    if f(1) == 0:<br>        print(“The function is balanced”)<br>    else:<br>        print(“The function is constant”)</pre><h4>Quantum circuit for Deutsch-Jozsa</h4><p>It’s time to go deeper! We will jump into the rabbit hole! What does the quantum circuit of Deutsch-Jozsa look like? Look at this picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-CcvTdpjsvA_8dpFH3HMTQ.png" /><figcaption>Quantum circuit for Deutsch-Jozsa problem. The case is the general case (n qubits initialized). The |psi_x&gt; are the different phases of the quantum algorithm. Draw by the author.</figcaption></figure><p>Lot of things to look at it, right? So, let’s go.</p><p>When you start a quantum circuit, you initialize the circuit at the state 0. This is the |psi_0&gt; step. Each qubit will have the state 0 or the column vector (1, 0). This quantum circuit is a generalized model because you can create a quantum circuit with <em>n</em> qubits. You also need one qubit with the initialization at state 1; the X quantum gate does this. The X-gate performs a bit flip operation; it inverts the state, passing from 0 to 1.</p><p>Hadamard Gate<br>It’s a single-qubit operation mapping the state |0&gt; and |1&gt; of the qubits into a superposition state. Hadamard has the letter H to represent the gate, and the corresponding mathematical representation is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*TEyrQTB6dXr8KyS5Tg6rRw.png" /></figure><p>When applied on |0&gt; and |1&gt; we have the corresponding states:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*rSsk5gaSQxWf9N_VgMhEUA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*bX7vLTUUNdfpZS9FWO_bww.png" /></figure><p>Every qubit is put in a superposition 0 and 1 states. These states are then passed to the oracle.</p><blockquote>We query the oracle with a superposition state!</blockquote><h4>Code for Deutsch-Jozsa’s algorithm</h4><p>It’s time to see how to code it. First, we need to import some packages to create the corresponding objects.</p><pre>import numpy as np<br>from qiskit import QuantumCircuit, transpile, assemble, Aer, IBMQ, execute <br>from qiskit.quantum_info import Statevector<br>from qiskit.visualization import plot_bloch_multivector, plot_histogram</pre><p>Here we have all the packages we need to create the oracle and implement the Deutsch-Jozsa algorithm. We will use oriented-object programming to generate the quantum algorithm.</p><p>The class will contain three methods. The first is the init() , the second is the oracle() and the last is the algorithm dj().</p><p>The __init__() function will create an instance of the class. The parameters are the case (<strong>balanced</strong> or <strong>constant</strong>) to be passed to the oracle and the string of states that you will test an input (as ‘1001’, ‘0010’ for four qubits input). The init() function will generate the correct number of qubits required for the algorithm.</p><p>The oracle() function will create a proper QuantumCircuit(). The objective is to create a custom gate to insert it into the final algorithm. The oracle will consider two cases. <strong>Constant</strong>: the function will transform the state to return the state 0s state as output. In the <strong>balanced</strong> case, the function will flip all the 1s in input to 0s. Then apply CNOT gates and flip the 1s again. You have your oracle for Deutsch-Jozsa.</p><p>Now, the dj() function, is where we create the |psi_x&gt; where x = 0, 1, 2. At first, we make the output qubit (n+1 qubit), applying X-gate and then Hadamard-gate. The rest is to initialize all the rest of the qubits with Hadamard-gate, add the oracle on all qubits, then use Hadamard-gate again and create the measurement of all qubits without the output one.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/686d22194e3419cb438f56426f79cec9/href">https://medium.com/media/686d22194e3419cb438f56426f79cec9/href</a></iframe><p>Let’s get it run!</p><pre>dj_object = DeutschJozsa(&#39;constant&#39;, &#39;0110&#39;) # Call the class and generate the instance with the constant case and the input state string ‘0110’</pre><pre>dj_circuit = dj_object.dj() # Create the quantum algorithm by calling the dj()</pre><pre>dj_circuit.draw(&#39;mpl&#39;) # Make the visualization of the circuit</pre><p>The result is this circuit:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ut-5uhVmNX_i8Yw09QVxtA.png" /><figcaption>Quantum circuit of 5 qubits for Deutsch-Jozsa’s algorithm generated by the class DeutschJozsa(). H stands for Hadamard-gate, X stands for X-gate, Oracle stands for the oracle-gate generated by the oracle function, and the black symbols on the right correspond to the measurement.</figcaption></figure><p>Now we need to run it both in a simulator and on a real device (oh yeah!).</p><h3>Running a quantum algorithm.</h3><p>First, we will try the quantum algorithm with a perfect simulator. This will be our baseline. We will use all of the functions described in the part of the main components of Qiskit. Let’s do it:</p><pre>qasm_sim = Aer.get_backend(&#39;qasm_simulator&#39;) # Create a backend simulator</pre><pre>transpiled_dj_circuit = transpile(dj_circuit, qasm_sim) # Transpile the code into fundamental gates, this will break the oracle into its components</pre><pre>qobj = assemble(transpiled_dj_circuit) # Then assemble each gate into a new quantum circuit</pre><pre>results = qasm_sim.run(qobj).result() # Time to run it on the backend and get the results, the simulator is perfect, so it requires only one shot</pre><pre>answer = results.get_counts()# Extract the output state</pre><pre>plot_histogram(answer) # Plot it to visualize the corresponding histogram</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_7L0hnKq7QADS3g2Fu_M5Q.png" /><figcaption>Histogram of the probability for the output state ‘0000’ means that the input function is balanced.</figcaption></figure><p>All right, the result is a corresponding 100% probability that the function is constant. But it was easy and perfect because the qasm_simulator reproduces the behaviour of an ideal quantum computer without any decoherence. You made it, created a quantum algorithm for the Deutsch-Jozsa’s problem, and tried it with a simulator.</p><p>Now, let’s run the quantum algorithm on a real device. To do it, you will need an account on the <a href="https://quantum-computing.ibm.com/">IBM quantum experience</a> (it’s free, and you have access to quantum computer for free). When your account is created, you need to generate a token; it is your credential to use the IBM Quantum Cloud. On the main page, you have an ‘API token’; create one and copy the token. You will link your machine and the Qiskit library like this:</p><pre>from qiskit import IBMQ # Call IBMQ – API for the quantum cloud</pre><pre>TOKEN = &#39;paste your token here&#39; # Save your token here</pre><pre>IBMQ.save_account(TOKEN) # Connect your machine with the cloud</pre><pre>IBMQ.load_account() # Load account from disk</pre><pre>IBMQ.providers() # Print the group you belong to</pre><p>The code will print this:</p><pre>[&lt;AccountProvider for IBMQ(hub=&#39;ibm-q&#39;, group=&#39;open&#39;, project=&#39;main&#39;)&gt;]</pre><p>This means that you have a free account and access to the group ‘open’ for open-source and project ‘main’ because you are not part of a category for IBM. Let’s see what device we could use. To know that, we need to call the available backends:</p><pre>provider = IBMQ.get_provider(hub=&#39;ibm-q&#39;)<br>provider.backends()</pre><p>And the code (or API call) will generate this list:</p><pre>[&lt;IBMQSimulator(&#39;ibmq_qasm_simulator&#39;) from IBMQ(hub=&#39;ibm-q&#39;, group=&#39;open&#39;, project=&#39;main&#39;)&gt;,<br>&lt;IBMQBackend(&#39;ibmq_armonk&#39;) from IBMQ(hub=&#39;ibm-q&#39;, group=&#39;open&#39;, project=&#39;main&#39;)&gt;,<br>&lt;IBMQBackend(&#39;ibmq_santiago&#39;) from IBMQ(hub=&#39;ibm-q&#39;, group=&#39;open&#39;, project=&#39;main&#39;)&gt;,<br>&lt;IBMQBackend(&#39;ibmq_bogota&#39;) from IBMQ(hub=&#39;ibm-q&#39;, group=&#39;open&#39;, project=&#39;main&#39;)&gt;,<br>&lt;IBMQBackend(&#39;ibmq_lima&#39;) from IBMQ(hub=&#39;ibm-q&#39;, group=&#39;open&#39;, project=&#39;main&#39;)&gt;,<br>&lt;IBMQBackend(&#39;ibmq_belem&#39;) from IBMQ(hub=&#39;ibm-q&#39;, group=&#39;open&#39;, project=&#39;main&#39;)&gt;,<br>&lt;IBMQBackend(&#39;ibmq_quito&#39;) from IBMQ(hub=&#39;ibm-q&#39;, group=&#39;open&#39;, project=&#39;main&#39;)&gt;,<br>&lt;IBMQSimulator(&#39;simulator_statevector&#39;) from IBMQ(hub=&#39;ibm-q&#39;, group=&#39;open&#39;, project=&#39;main&#39;)&gt;,<br>&lt;IBMQSimulator(&#39;simulator_mps&#39;) from IBMQ(hub=&#39;ibm-q&#39;, group=&#39;open&#39;, project=&#39;main&#39;)&gt;,<br>&lt;IBMQSimulator(&#39;simulator_extended_stabilizer&#39;) from IBMQ(hub=&#39;ibm-q&#39;, group=&#39;open&#39;, project=&#39;main&#39;)&gt;,<br>&lt;IBMQSimulator(&#39;simulator_stabilizer&#39;) from IBMQ(hub=&#39;ibm-q&#39;, group=&#39;open&#39;, project=&#39;main&#39;)&gt;,<br>&lt;IBMQBackend(&#39;ibmq_manila&#39;) from IBMQ(hub=&#39;ibm-q&#39;, group=&#39;open&#39;, project=&#39;main&#39;)&gt;]</pre><p>Here we are; we can see many devices, backend (real device) and simulators. IBM has devices with more than one hundred qubits, but in open access, we have only access to 5 qubits devices. We put a string of four values (4 qubits for the string — x, and one for the output — y, 4+1=5).</p><p>Let’s try ibmq_manila:</p><pre>backend = provider.get_backend(&#39;ibmq_manila&#39;)</pre><p>Now our backend to do the calculation is the real device. Let’s rerun some previous lines:</p><pre>mapped_circuit = transpile(dj_circuit, backend=backend)# Transpile the circuit with the backend architecture</pre><pre>qobj = assemble(mapped_circuit, backend=backend, shots=1024)# Assemble into a new quantum circuit with Manila in the backend and a number of shots of 1024</pre><pre>job = backend.run(qobj) # Run it</pre><p>This step can be very long, depending on the use of the device. The first time it took me 30 minutes to get the results back. You can get the results and print them when your job is validated, in queued and run.</p><pre>result = job.result()# Get the result object</pre><pre>counts = result.get_counts() # Extract the dictionary containing the states with their corresponding number of appearances when measured</pre><pre>print(counts)</pre><pre>&gt;&gt;&gt; {&#39;0000&#39;: 974, &#39;0001&#39;: 8, &#39;0010&#39;: 8, &#39;0100&#39;: 25, &#39;1000&#39;: 8, &#39;1001&#39;: 1}</pre><p>Well, as you see, the result isn’t perfect due to the noise of the real device. We can visualize the corresponding histogram:</p><pre>plot_histogram(counts)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j1sIlMAlcQGvyYZbramsRw.png" /><figcaption>Histogram of the probabilities for each output state obtained by running the Deutsch-Jozsa algorithm on the Manila device. The state ‘0000’ has the best probabilities leading to the evaluation constant of the function.</figcaption></figure><p>Look, take a breath; you did it!! You built a quantum algorithm and tested it on a simulator and a real device. Congratulation! You know now how to code and use Deutsch-Jozsa’algorithm with Qiskit and IBM quantum.</p><h3>Take away</h3><ul><li>Deutsch-Jozsa is a quantum algorithm used to determine the behaviour of a function, constant or balanced. The algorithm has an oracle that we need to query to obtain an answer once.</li><li>DJ is the quantum algorithm which reaches a quantum advantage. The time complexity is exponentially faster than the classical approach.</li><li>The quantum algorithm is equipped with an oracle, a black-box operation. This black-box is a function where we don’t know the properties and need to query the function to obtain them.</li><li>An oracle is necessary a unitary matrix because it needs to be reversible to follow unitary operators’ rules and doesn’t lose information from input to output.</li><li>Qiskit possesses six modules. Two contain fundamental functions to create and use a quantum algorithm (Aer and Terra). Four are domain specifics and have algorithms for real-world applications (Optimization, Machine Learning, Finance and Nature).</li><li>We create a class containing the components of the Deutsch-Jozsa quantum algorithm. Easily usable with only the case scenario and the bit string as input. The code is agnostic of the bit string length, but you must be careful of the number of qubits needed to run the quantum algorithm.</li><li>A quantum algorithm can be run locally with simulators. The results are usually perfect because a simulator is a quantum computer without noise. This noise provides a different circuit output due to destructive decoherence.</li><li>The quantum algorithm needs to be run multiple times to generate a probability distribution of the output. The output with the highest probability is the one we keep as a “result.”</li><li>We used a lot of concepts different from the classical world, be sure to fully understand the different steps and how they affect the quantum circuit to understand the quantum computation of the algorithm.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b19fe0711187" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Classical versus Quantum Computing]]></title>
            <link>https://medium.com/swlh/classical-versus-quantum-computing-cb04f8948d4b?source=rss-9cf1f3f55c40------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb04f8948d4b</guid>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[classical-computing]]></category>
            <dc:creator><![CDATA[Christophe Pere]]></dc:creator>
            <pubDate>Thu, 21 Jul 2022 01:42:35 GMT</pubDate>
            <atom:updated>2023-07-17T02:57:40.226Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8r-_9kLAyAVtCQCE06cGxQ.jpeg" /><figcaption><a href="https://www.pexels.com/photo/art-pattern-purple-texture-12214777/">Photo by Marek Piwnicki from Pexels</a></figcaption></figure><p>The quantum revolution</p><p>It’s interesting to compare both computing technologies to demystify the quantum world.</p><h3>The architecture of a classical computer</h3><p>Here you are close to the rabbit hole. The time has come to jump out of your reality. Alice discovered a new world down the rabbit hole, just like you in the following pages. We will look at a basic level inside a classical computer to avoid shock and compare the architecture with the quantum computer.</p><h4>Components of a classical computer</h4><p>First of all, let’s discuss classical computers. Most of us use a laptop daily, whether for work, surfing the Internet, checking emails, or writing with text editors. How? What are the main components of a classical computer?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*6xgEv7AEc7_ujDGDmitaPQ.png" /><figcaption>Simplistic structure of components’ interaction in a classical computer — Draw by the author.</figcaption></figure><p>The figure below shows the basic architecture for a classical computer, yours and mine.</p><ul><li>The input can be keyboard keys, mouse movements, and actions like copy and paste. It could be an interaction between you and the computer or an internal process.</li><li>The central processor unit (CPU) will receive the input and compute the action. The CPU is only meant to calculate.</li><li>If information is needed, the primary memory called random access memory (RAM) helps to store data with — high-speed access. If you shut down the computer, the information in the RAM is destroyed.</li><li>The second memory (disk storage) is when you want to keep the information or when computations involve so much data that you write iteratively on the disk.</li></ul><p>A computer is just a way to manipulate and transform information. But the data needs to be in the language of the CPU. What is this language? The computer or CPU only speaks in bits or binary numbers, 0’s and 1’s. 0 means “off” and 1 “on.” Bits correspond to the two states of a transistor. Transistors are electrical switch devices. If the transistor is on, the current passes through (value 1 for a bit). If the transistor is “off,” the current is stopped (value 0).</p><h4>When Bits create Bytes to store more information</h4><p>Before diving into the quantum world, it’s crucial to have a good survey on how the information is stored in a classical computer. If we just take one bit of information, we are very limited in the amount of information we can store. 0 or 1 is called a bit, the minimal information unit a classical computer needs. If you group bits in a sequence, for example, eight bits, you form a byte. Then the magic happens. You will have access to 256 possible values, and every quantum of information, document, computation, picture or movie is based on bytes. Imagine long sequences of 0’s and 1’s like in The Matrix.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*OseoC4K0nDj7bF2y-PyGFQ.png" /><figcaption>How to use binary encoding in a byte for a classical computer — Draw by the author.</figcaption></figure><p>With eight bits, you can store 2⁸ bits of information. Imagine that a hard drive has one terabyte, it’s 10¹² bytes, and in each byte, you store 2⁸ bits of information. It’s a lot.</p><p>Example: consider a byte like a letter (ASCII convention); a novel contains around 300,000 words. We could use an average of 4 letters per word, leading to 1,200,000 bytes, equivalent to 1,2 megabytes or Mb. Your hard drive can contain approximately 833,333 books. Take a coffee and start reading.</p><h4>The deterministic aspect of classical computation</h4><p>The beauty of classical computation lives in the deterministic world. Deterministic means that there is no randomness in the evolution of the system. The output will always be the same if you redo the same operation repeatedly.</p><p>A processor obeys Boolean algebra’s rules because it uses binary variables and logical operations (logical gates). All of this is deterministic by nature.</p><p>It’s why we see thematics like explainability or interpretability in computer science. Explainability is used as the knowledge we have of a model. We could extract the way the model use information and how. Explainability teaches us the mechanics inside the model and answers to the “how.”</p><p>Interpretability is the other way to understand the decision of an algorithm. Interpretability means that the cause and the effect in the decision-making are known.</p><h4>Classical operations are made in sequential order</h4><p>The CPU has the power of operations. When you buy a laptop, the packaging says “3.4GHz,” you may know that the processor can do 3.4 billion operations per second. These instructions are executed sequentially by the processor. It passes to the next instruction only if the previous one is done, like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*K9npg4VrAnSFuKuhUua5FA.png" /><figcaption>Sequential operations in a classical computer — Draw by the author.</figcaption></figure><p>You can visualize it as reading a text or a book. You don’t read all pages in a block. You follow one line after another to follow the story thread.</p><h4>Classical operators: the logic gates</h4><p>Congrats, you reach the point where you know how to store information on a computer. You understand that a computer uses sequential operations, but how do you use or process the bits? You will need operators to manipulate and transform the bits. These operators are at the level of the hardware. They are called logic gates and allow the processor to execute the instruction with fidelity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*dH1D27kHjeJCRdBNEBmThA.png" /><figcaption>Operation through the gate — Draw by the author.</figcaption></figure><p>A logic gate is usually a simple operation acting on two bits in input and output one bit. Seven basic logic gates exist OR, XOR, NOR, XNOR, AND, NAND, and NOT. I will not go through all of the logic gates but look, take the NOT and the AND gates. We will generate what we call a truth table:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*2A5f7rWXZSSl8l0lBp_y7Q.png" /><figcaption>Not and And gate — Draw by the author.</figcaption></figure><p>As you see in the picture, the logic gate NOT will flip the value of the bit, and the AND gate will output “1” only if the two inputs are 1. You can see it as a multiplication 0x1, and 0x0 will output 0, but 1x1 will equal 1.</p><p>One interesting thing is that logic gates could perform non-reversible operations, corresponding to loss of information. In the case of the AND gate, we can’t reverse the computation when we have the output because we don’t have the information about each separable bit or state of the bit. The maturity of classical technology will enable you to think in terms of logic gates. The current abstraction of all languages passes above this layer and helps developers to have a better and less complicated life.</p><h3>The architecture of a quantum computer</h3><p>A quantum computer is more complicated than a classical one because you need more layers to process the information. The figure below provides you with an overview of the building blocks of a quantum computer. You could see four layers behind the application (compiled quantum algorithm).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*xqVgZW3TIyfkG6NErJ4Q5w.png" /><figcaption>The architecture of a quantum computer — Draw by the author.</figcaption></figure><p>The process can be cut into ten steps dispatched in five layers. It’s a control loop where the information will pass two times in each layer. I will use terms like quantum circuit, quantum bits (qubits) and quantum gates to explain the concept of a quantum computer, but I will teach you what they are later in the chapter. So don’t be afraid; the quantum architecture is just here to see the differences from the classical approach.</p><p>1 - When we code the quantum algorithm, the application layer is the first and closer to us. This layer compiles the quantum circuit into the language of the computer (like binary assembly in a classical computer)</p><p>2 - The logical layer is an interesting part of the quantum computer. This step will deconstruct your quantum circuit into fundamental gates. You can create high-level quantum gates in your circuit, but the logical controller will deconstruct your gate into fundamental gates to replace your high-level gate. This is due to the operations done on qubits; inside the quantum computer, just a few quantum gates are implemented.</p><p>3 - Quantum error correction: a big name for this step. The actual quantum computers are noisy, meaning that they have lots of destructive decoherence where the qubit loses the information. This loss changes the result of the algorithm. The typical architecture introduces a layer that modifies the quantum circuit and makes it robust to error, called fault-tolerant. Controllers introduce a specific waveform to correct the error.</p><p>4 - The virtual layer is a controller between the virtual and physical environments (steps 5, 6, 7). It keeps the structure of the quantum gates and quantum bits.</p><p>5 - We enter the quantum region (steps 6 and 7) on a physical device. The qubits are not virtual. They are physical components of the machine. The goal here is to encode the data into qubits. This layer is the storage of quantum information.</p><p>6 - Step 6 is where the magic happens. The computer will run the computation with physical components; it’s the processing of quantum information. Your quantum circuit will be executed, and the value of the qubits will change according to the operations you want to generate a result.</p><p>7 - No intermediate result of quantum mechanics can be viewed without measurement, which changes the computation. This last step in the physical region observes to measure the result of the calculation. The observation will lead to a collapse of the quantum state of each qubit. They become classical information.</p><p>8 - We must pass again by the virtual environment to translate the hardware readout signals into a virtual qubit measurement.</p><p>9 - Quantum error correction filters the results and clears statistical errors. This step is called syndrome measurement; the objective is to diagnose which qubit admits an error. Most of the time, they are Pauli errors meaning that the quantum logic gates operate on another operation. Pauli gates will be explained in the following subsections.</p><p>10 - This last step provides the result in a readable format.</p><p>Now we know the basics of classical computers, enough to compare them with the quantum computer. Technology evolves so quickly that it is essential to mention the time we reach them.</p><blockquote><strong>Quantum computers are based on quantum mechanics. They are fast compared to classical ones, but they also have cons. They are not magical, keep this in mind; it’s not because they are different or based on another physics that makes them magical.</strong></blockquote><p>Unfortunately, quantum technology is not as mature as classical computing. A QC doesn’t yet possess a quantum computer’s primary memory (QRAM) equivalent to the RAM in classical computing. Much research is done on QRAM; creating this component will allow researchers and industries to access faster and more complex quantum algorithms.</p><h4>Quantum Bits</h4><p>Previously we have discussed bits, the fundamental information unit for a classical computer. A QC also needs its essential component called quantum bits or qubits. They are more powerful than their classical counterpart.” They can take the values 0’s or 1’s and the infinite possibilities between them. Wait, what?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*KlKHIWfj4SU-7kyxMzEgYA.png" /><figcaption>Classical versus quantum bits — Draw by the author.</figcaption></figure><p>And the quantum journey begins. The figure above shows the difference between a classical bit, two values, 0 and 1, represented in two dimensions (2D) and their quantum twins. A qubit can be visualized in 3D as a sphere; as we will see later, it is called the Bloch Sphere. 0 and 1 are the values at the poles, north and south, respectively. But the qubit could also take every other position on the sphere. So, we could store lots more information into a qubit rather than a bit.</p><p>The significant difference is that bits are discrete values and qubits are infinite and continuous (called states). When a state isn’t 0 or 1, it is in superposition because it is somewhere between.</p><p>Probabilities lead the world of quantum mechanics. It is due to the nature of the microscopic scale of matter. Unfortunately, computations will follow the same way. The output has a probability of appearance. That means there are multiple possible outputs for the same input. The computation result will be a probability distribution because you must run your algorithm numerous times.</p><h4>Parallel instances</h4><p>One of the advantages of quantum computing is that you don’t need sequential operations or loops. Quantum logic allows the machine to process the computations at the same time. A quantum computer will evaluate every possibility at the same time. A QC can theoretically do 2^n operations at a time.</p><h4>Linear algebra is enough</h4><p>The rules of quantum computing are simple; they lie in linear algebra and always have. Classical computing is about Boolean algebra, but the strength of QC lies in vectors, matrices, and tensors operations. Figure 4 shows what those mathematical objects are. When you create a quantum circuit, you will use gates, also called operators. These gates are matrices applied on single qubits or multiple qubits. A quantum circuit can be seen as a series of matrix multiplications. I will teach you how and why all along with this book. The figure below shows you the different structures we can and will use in quantum algorithms. You have the column vector. Basically, a qubit is represented by a column with two values. Matrix and tensor are the representation of the operators and complex operators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*xIc-bYnzD5gUGwDCtAOPig.png" /><figcaption>Representation of the different forms of an operator — Draw by the author.</figcaption></figure><h4>Quantum Gates</h4><p>In quantum computing, you also need operators to process the information. These are the quantum gates, and the differences with classical logical gates are insignificant. Quantum gates also take binary inputs and outputs. Unlike classical gates, quantum gates must be reversible. Reversibility is retrieving the inputs using the output and inversing the operation. If A is the input and I multiply by the matrix X to obtain B, I can invert the process starting with B, multiply by X^-1 (the inverse matrix of X) and get the input A. The theory of quantum mechanics teaches us that we can’t lose information.</p><p>Quantum gates are unitary matrices; their conjugate transpose is also their inverse. The notation for this operator is represented with a dagger like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*BqYCx8VqZI8Otr_BjsEa2w.png" /></figure><p>Don’t run now. The conjugate transpose operates as follows:</p><ul><li>Transpose the vector or the matrix</li><li>Compute the conjugate</li></ul><p>The conjugate of a scalar is itself; the conjugate of a complex number is the opposite of the imaginary part.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vo6ZKnu4B_F1P0at5C0LSQ.png" /></figure><p>Quantum gates leverage superposition and entanglement, two significant components of quantum mechanics. If two qubits are entangled, they are still in the quantum gates process. They don’t collapse.</p><p>Quantum gates are mainly used on single qubits or two qubits, so they are 2x2 or 4x4 with orthonormal rows.</p><h3>Quantum speed-up</h3><p>Companies look for different things when a new technology appears on the market. Quantum computing isn’t an exception. What can quantum computing bring to the market? How can quantum algorithms be of any interest to a company? We could look at several advantages when we want to test or use another technology. We can look at the ease of use of the technology or algorithms. In the case of quantum algorithms, it will depend on the problem. We can look at the complexity. Are quantum algorithms less complex than their counterparts? We can look at the energy consumption; this is a point where quantum computers could win with a stable consumption in energy compared to a classical architecture where the power scale exponentially with the power of computation.</p><p>Or we can look at the speed-up with the decreasing complexity (Big O notation). You gain a quantum advantage when the quantum algorithm is faster than the best classical implementation.</p><h4>Acceleration</h4><p>The speed-up is the most used metric to determine if a quantum algorithm is better than the best classical implementation. You can see speed-up as the grail researchers and industries are looking for. There is a bias here because you can only measure two algorithms (classical and quantum) that will do the exact computation. We can’t use speed-up when we try to create quantum algorithms to solve intractable problems for classical computing. We can’t compare.</p><p>For example, two protagonists in quantum information science, Alice and Bob, are in a game. Bob places a ball in one of the six drawers of a cabinet. Alice has no idea which drawer contains the ball.</p><p>Classical Alice:</p><ul><li>Best case: Alice opens the first drawer, and the ball is in it. End of the game.</li><li>Worst case: Alice opens five drawers to know where the ball is. She doesn’t need to open the sixth drawer to know where the ball is. Either it was in the fifth drawer, or it wasn’t. It must be in the sixth if it wasn’t in the fifth drawer.</li></ul><p>Quantum Alice: The function evaluation in quantum computing tells Alice where the ball is. She only needs one try to find the ball.</p><p>How is it possible? Think of Alice when she opens one drawer after another. She does it in sequential operation. “I open the first drawer and look inside to see if the ball is in it. If not, I open the second….” A quantum computer and a quantum algorithm taking advantage of this property will evaluate all the probabilities in one of the presence of the ball in the drawers. The quantum algorithm will output the drawer number with the best probability. Alice will just open the corresponding drawer to find the ball.</p><p>There is a quantum speed-up comparing the worst classical Alice case and the quantum Alice because the quantum case is faster than the classical one.</p><p>We can define the quantum speed-up when the computation time is less for the quantum algorithm than its classical counterpart.</p><p>But do we need just that? A slight difference in computation time? Exponential speed-ups are required to prove that there is a quantum advantage. That implies the necessary use of a quantum computer. There are different types of quantum speed-up, like linear quantum speed-up. A quantum algorithm will be linearly faster than its classical implementation. There are also exponential speed-up and polynomial ones. We will see examples through this book of their advantages.</p><p>There will be a real quantum advantage when quantum algorithms run exponentially or in polynomial time on the noisy intermediate-scale quantum (NISQ). The current quantum computers are not perfect; they have noise and decoherence, so it’s hard to obtain a real advantage with our few qubits at our disposal.</p><blockquote><strong>Big O analysis</strong></blockquote><blockquote>In the literature, you will find another way of evaluating the quantum speedup of a quantum algorithm. Researchers use the Big O notation to determine an algorithm’s space and time complexity. Big O is a notation of the measure of the upper bound performance of an algorithm (worst runtime). One of the ways to see it is to determine the number of steps or the number of iterations of an algorithm. Comparing the complexity of both classical and quantum versions of an algorithm shows the speed-up of the quantum version theoretically if the complexity is reduced.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*lzGcP1pmErN7htrFhxw2FQ.png" /></figure><blockquote>Where linear time is O(n), quadratic time is O(n2), logarithmic time O(n log n), exponential time 2polyn, polynomial-time 2O(log n) and factorial time O(n!).O(1) is excellent, O(log n) is good, O(n) is fair, O(n log n) is bad, but O(n2), O(2n) and O(n!) are horrible in terms of complexity.</blockquote><h3>Quantum advantage</h3><p>Quantum supremacy is an older term for the next step after the quantum speed-up. “Supremacy” was judged inappropriate, so researchers replaced “supremacy” with “advantage.” A quantum advantage is a programmable quantum computer that could run a quantum algorithm that a classical one can’t in a feasible amount of time.</p><p>For example, in 2019, Google claimed that they realized a computation in 200 seconds compared to 10,000 years in a classical computer. Even if this claim was rebuked by IBM, which shows that the calculation can be done in days on a classical machine with the corresponding optimization, this announcement shed light on quantum computing. More recently, in 2021, China claimed a quantum advantage, running one algorithm 10 million times faster on a superconducting quantum computer.</p><p>Another achievement was to run another algorithm one septillion times faster.</p><p>Quantum advantages can be expected shortly by some communities and industries. These milestones are expected to validate all the efforts and investments in the quantum computing field. It’s why you need to learn how to use a quantum computer and what quantum algorithms exist now to be ready when the hardware is fault-tolerant (robust to the noise).</p><h3>Take away</h3><ul><li>Classical and quantum computing are different in many ways, but each has pros and cons.</li><li>Classical computers use bits and bytes to store information in a binary format.</li><li>Both classical and quantum computing are governed by what we call gates. They are similar but also different because their physics is different.</li><li>Quantum computing is not mature enough to be used like classical computing. Quantum algorithms need to be coded at a more fundamental level. It’s why quantum gates are significant.</li><li>The classical world is deterministic; measures of the quantum world are probabilistic.</li><li>Deterministic computation implies you can rerun the exact calculation to obtain the same result.</li><li>On the opposite, probabilistic computation is led by probabilities. The result of a calculation can only be approximate (the result will be different with a variation) because of the probabilistic behaviour.</li><li>Information can’t be lost in the quantum world, so every operation must be reversible. This principle has important implications in the computation process.</li><li>Quantum computing is governed by a different sort of mathematics called linear algebra. Those familiar with the machine learning domain will find similarities with quantum computing.</li><li>A quantum algorithm uses the properties of quantum mechanics, such as superposition and entanglement.</li><li>Some classical algorithms can be run on a quantum computer, but they are not quantum algorithms.</li><li>A quantum algorithm will estimate the operations in parallel rather than sequentially for a classical algorithm.</li><li>Quantum advantage is the speed-up gained from quantum computing over the speed of classical computers’ same types of operations.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb04f8948d4b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/classical-versus-quantum-computing-cb04f8948d4b">Classical versus Quantum Computing</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Qiskit — new modules]]></title>
            <link>https://medium.com/swlh/qiskit-new-modules-306c384503be?source=rss-9cf1f3f55c40------2</link>
            <guid isPermaLink="false">https://medium.com/p/306c384503be</guid>
            <category><![CDATA[simulation]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[qiskit]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <dc:creator><![CDATA[Christophe Pere]]></dc:creator>
            <pubDate>Wed, 22 Jun 2022 13:10:07 GMT</pubDate>
            <atom:updated>2022-06-22T13:10:07.682Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qptjDR0c9mHb9E5gflWGuA.jpeg" /><figcaption>Copyright: <a href="https://unsplash.com/photos/VeRu9uJQ6VQ">Unsplash</a></figcaption></figure><h3>Qiskit — new modules</h3><p>Time to do some quantum stuff</p><h3>Introduction to Qiskit</h3><p>IBM released in 2017 a framework to use their quantum computers and simulators. This library, named Qiskit (<a href="https://qiskit.org/">https://qiskit.org</a>), is a framework written in python and built on top of the OpenQASM language (the machine language).</p><p>Initially, Qiskit consisted of four modules named:</p><ul><li>Terra: allows the user to work on the noisy quantum computer at the level of pulses, circuits, and algorithms. This module is the core component on which the rest of Qiskit is built.</li><li>Aer: is the module to use and create performant simulators and representations of the current noisy devices. The module provides realistic noise to test quantum algorithms like a real device.</li><li>Ignis: is the module to mitigate noise in a quantum circuit (application of filters). The module also provides tools to estimate the noise in the result and apply correction to minimize the effect of the noise. Ignis is applied on top of Aer and Terra.</li><li>Aqua: is an acronym for Algorithms for QUantum computing Applications. It provides a long list of quantum algorithms and built-in elements to compose and construct new quantum algorithms.</li></ul><p>Ignis and Aqua are currently deprecated. Recently, the IBM team released new modules specific to the applications and replaced the two previous modules to extend their methods.</p><ul><li>Optimization: it’s a module that contains all the quantum optimization algorithms (Quantum Approximate Optimization Algorithm, Variational Quantum Algorithm…). The package provides building blocks for quickly prototyping new quantum algorithms.</li><li>Machine Learning: is a small module containing datasets and a few quantum machine learning algorithms (quantum support vectors, quantum generative adversarial networks, and variational quantum classifiers).</li><li>Finance: contains datasets and building blocks to study stock problems and portfolio optimizations.</li><li>Nature: is a module to study the behaviour of the atomistic energy levels. It provides building blocks to compute the ground state energy, molecule interaction, and excited states. The code includes chemistry drivers to calculate the molecular interaction.</li></ul><h4>How to install Qiskit?</h4><p>If you go to the library’s website, the team provides the way to install Qiskit on different OS. I will assume that you know how to use command lines and have a python version installed. So, the easiest way is to use this command:</p><pre>pip install qiskit</pre><p>or</p><pre>python -m pip install qiskit</pre><p>Depending on the version of python and how it is installed, you can have pip3 instead of pip and python3 instead of python.</p><p>To install the optimization module, you need to use this command line:</p><pre>pip install qiskit-optimization</pre><p>To install the machine learning module, you need to use this command line:</p><pre>pip install qiskit-machine-learning</pre><p>To install the finance module, you need to use this command line:</p><pre>pip install qiskit-finance</pre><p>To install the nature module, you need to use this command line:</p><pre>pip install qiskit-nature</pre><h4>How to learn Qiskit?</h4><p>Qiskit is one of the most used quantum libraries on the market. Currently, the community is huge and has built lots of tutorials. But, IBM quantum also focuses on the education part. It’s their primary focus. The company wants to educate people to be ready when the market explodes.</p><p>The maintainers, developers and Qiskit advocates contribute to people&#39;s learning progress by providing a big online textbook” The beta version allows you to manipulate snippet of code and answer questions to test your understanding of the quantum world. You can find the textbook here: <a href="https://qiskit.org/learn">https://qiskit.org/learn</a></p><p>The authors provide tons of materials to start your learning journey (<a href="https://qiskit.org/learn/course/prerequisites">prerequisites</a>). Quantum computing resources, like an <a href="https://qiskit.org/learn/course/introduction-course">introduction</a>, <a href="https://qiskit.org/learn/course/multiple-qubits-and-entanglement">multi-qubits and entanglement</a>, <a href="https://qiskit.org/learn/course/quantum-states-and-qubits">states and qubits</a>. These resources will help you go deeper with <a href="https://qiskit.org/learn/course/quantum-hardware-circuits">hardware</a> and <a href="https://qiskit.org/learn/course/quantum-hardware-pulses">microwave pulses</a>, <a href="https://qiskit.org/learn/course/quantum-protocols-and-quantum-algorithms">quantum protocols</a>, <a href="https://qiskit.org/learn/course/quantum-algorithms-for-applications">quantum algorithms and applications</a>.</p><p>For the more hungry you also have access to <a href="https://qiskit.org/learn/course/machine-learning-course">quantum machine learning</a> courses (based on the <a href="https://qiskit.org/learn/summer-school/quantum-computing-and-quantum-learning-2021">summer school given in 2021</a>) and <a href="https://qiskit.org/learn/course/games-and-demos">quantum games</a>. The previous version of the <a href="https://qiskit.org/learn/summer-school/introduction-to-quantum-computing-and-quantum-hardware-2020">summer school (2020) had a focus on hardware</a>.</p><p>For those who prefer to watch videos I highly recommend the <a href="https://www.youtube.com/qiskit">youtube channel of Qiskit</a> providing documentaries, courses, seminars and more.</p><h4>How to contribute?</h4><p>You have different ways to be involved in the quantum community and in Qiskit:</p><ul><li>Qiskit is an open-source library you can contribute to the <a href="https://github.com/Qiskit">GitHub issues</a></li><li>Participating in the <a href="https://ibm.co/joinqiskitslack">Slack discussions</a></li><li>Participating in IBM quantum challenges to solve real applications</li><li>Participating in summer schools (2 weeks in July)</li><li><a href="https://qiskit.org/advocates/">Becoming</a> an <a href="https://github.com/qiskit-advocate/application-guide">advocate</a></li><li>Building tutorials or projects using Qiskit to share what you learn</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=306c384503be" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/qiskit-new-modules-306c384503be">Qiskit — new modules</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Thousand Brains Theory: A Review]]></title>
            <link>https://medium.com/data-science/a-thousand-brains-theory-a-review-3ea6bbeeced0?source=rss-9cf1f3f55c40------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ea6bbeeced0</guid>
            <category><![CDATA[review]]></category>
            <category><![CDATA[machine-intelligence]]></category>
            <category><![CDATA[brain]]></category>
            <category><![CDATA[neuroscience]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Christophe Pere]]></dc:creator>
            <pubDate>Sun, 26 Sep 2021 16:35:56 GMT</pubDate>
            <atom:updated>2021-10-08T20:30:59.459Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fVniO2FZsuP4wwfJXdpf5g.jpeg" /><figcaption>Unplash: <a href="https://unsplash.com/@halacious"><strong>Halacious</strong></a></figcaption></figure><h4><em>A new theory on intelligence and how the neocortex works.</em></h4><h3>Introduction</h3><p>For a long time, I have been following <a href="https://numenta.com/">Numenta</a>, a startup of neuroscientists whose goal is to understand the neocortex to reproduce the mechanisms in learning algorithms.</p><p>The founder, Jeff Hawkins, wrote the book <em>A Thousand Brains: A New Theory of Intelligence</em>. Attractive title for me who loves neuroscience and artificial intelligence. In his book, the author gives a history of theories about the brain and intelligence. He explains with anecdotes and experiences how he arrived at his theory.</p><p>His hypothesis is interesting and changes the way we compute all the actual machine learning algorithms:</p><blockquote>The hypothesis I explore in this chapter is that the brain stores all knowledge using reference frames, and thinking is a form of moving. Thinking occurs when we activate successive locations in reference frames. p.71</blockquote><p>In this blog post, I will only talk about the two first parts of the book 1) <em>A New Understanding of the Brain</em>, and 2) <em>Machine Intelligence</em>. The third part is about <em>Human Intelligence</em> but, I’m not going to explain it. I think the readers should make their own opinion about this part and not the biased vision I will provide them.</p><p>Let’s go.</p><h3>A New Understanding of the Brain</h3><p>The author builds his theory based on Mountcastle (1978)[1]. In this paper, he explains that the neocortex is a cortical algorithm. Mountcastle describes it as a general algorithm without detail about the <em>algorithm</em>.</p><p>The neocortex can be seen as a tensor with the same computational unit cloned a hundred thousand times. Indeed, the neocortex contains 150,000 cortical columns (see them as a neural layer containing a fixed number of neurons). Each cortical column is composed of 100 mini-columns. The best way to visualize this architecture is to think of a box of spaghetti. The box is the cortical column, and the spaghetti are the mini-columns.</p><p>Well, here you have a grasp of what is a cortical column. Now, imagine that this cortical column is a lego block and to build the neocortex you place a lot of cortical columns against each other and connect them in order to create a 3D network. That’s where the beauty lies. Each column is almost identical no matter where you look except for a few details. Each column can compute any stimulus or sense (hearing, smell, touch, taste and vision).</p><p>Now, think of an individual column. It can analyze and process the input signal, no matter the type of signal. So, each column can also predict an output. That means 150,000 predictions at each instant. The neocortex <strong>predicts thousands of realities</strong> with a continuous-time step. This is <strong>anticipation</strong>, consciousness doesn’t see it unless if it makes <strong>mistakes</strong>. You learn by analyzing the errors.</p><p>But, what does the brain learn? If all signals are perceived similarly. If the brain areas are not easily differentiable. How does the brain learn?</p><p>All signals are processed and computed at an identical location. How can the brain determine distances? Determine that the sound comes from a particular side. How does it know which signal to the primary brain is needed to reach a specific space to grasp an object? What does the brain learn from its perception of reality?</p><p>We learn a <strong>model of the world</strong>.</p><p>The brain, cortical columns, <strong>predict the future</strong>, of a few moments <strong>to adapt gradually</strong>. The <strong>learning appears from the mistakes</strong> it makes and provides <strong>updates to its model of the world</strong>.</p><p>Also, the brain has to make <strong>assumptions</strong> about what it perceives. No label on the environment surrounds it. It must first assume, as in an <em>unsupervised way</em>, and emit <strong>hypotheses</strong> to validate them afterwards with a <strong>label</strong>.</p><p>The neocortex will learn the shapes or <strong>global characteristics</strong> of objects. That will permit to recognize them regardless of additions or modifications of features. It, therefore, learns rules.</p><p>It must also learn <strong>mechanisms for retrieving information</strong>. The information it learns cannot be permanently available. The flow of information just shot down it. It must therefore learn by <strong>association</strong>. A smell will recall a memory. A texture brings back images, etc.</p><p>The neocortex will therefore act as a <strong>knowledge graph</strong>. A particular input will allow access to memories that are associated with a similar event. I visualize it as a database of understandings.</p><p>Unlike current general machine learning methods, <strong>the brain must learn continuously</strong> and in a <strong>doubly dynamic space</strong>. The world moves, and the brain moves in it. We could see it as <strong>continuous reinforcement learning</strong> or <strong>continuous exploration</strong>.</p><p><strong>Dynamism</strong> will allow the neocortex to <strong>create connections</strong> between events and sensations. Also, it will be able to learn the <strong>effects</strong> of the movements it generates. It is <strong>sensory-motor learning</strong>.</p><p>The brain needs to predict the continuous-time of events to be able to move and act in the environment. But, it needs to do <strong>two</strong> types of predictions. The one for the environment. The second, his representation inside the environment.</p><p>So, the brain learns and creates <strong>reference frames</strong> with the <strong>location</strong>. A reference frame is like a <strong>grid</strong> of the environment and objects. The brain will not save an image of each thing but a representation of points of interest. It’s like you have multi mesh grid of the world in your head. Each cortical columns can learn <strong>hundred</strong> of object.</p><p>The world, for the brain, is a <strong>sequence of memory</strong> (dynamics). Location is needed to <strong>associate position</strong> and <strong>memory</strong> because it allows you to find your way and move.</p><p>A current equivalent in the AI domain is the <strong>RNN family and attention mechanisms</strong>. The <strong>world model</strong> creates by the neocortex is a <strong>combination of sensory input, reference frames and location</strong>. The neocortex isn’t responsible for the movement and map creation. It needs the <strong>old brain</strong> to do it. Mostly the <em>hippocampus</em> and the <em>entorhinal cortex</em>.</p><p>Each neuron will search for the corresponding map between hundreds. It’s working as <strong>associative memory</strong> with the help of dendrites. In the citation provided in the introduction. The author hypothesizes that <strong>knowledge is encoded in the reference frames, and location</strong>, or the ability to connect the dots, <strong>creates thinking</strong>. Thinking is the selection of the corresponding cortical column. It’s possible because <strong>reference frames learn a representation of the world, not just objects. </strong>The location allows the cortical columns to choose the corresponding map.</p><p>Where the name of the theory comes from? As explained before, the neocortex is based on cortical columns based on mini-columns. This approach is a <strong>thousand brains</strong> <strong>theory</strong>.</p><p>In this theory, cortical columns are relatively similar but could only <strong>retain a fixed size of knowledge</strong>. So the knowledge is <strong>spread</strong> inside the 150,000 columns but with <strong>overlap</strong>. If a part is injured, the information isn’t lost.</p><p>But, there is a problem here. If hundreds of columns retain the same information or a version of the information, how does the brain <strong>perceive only one thing</strong>? It’s called the <strong>binding problem</strong>.</p><p>How could the cortical columns resolve the binding problem? The simple answer of the author is: <strong>by voting</strong>. For me, each column will predict a piece of information with a <strong>probability</strong>. If the information reaches the majority, the reference frame is selected.</p><p>The magic part is that the <strong>neuron</strong> providing the vote is <strong>always the same</strong> in the cortical columns. Every time a vote is needed, the <strong>same neurons</strong> will be activated through cortical columns.</p><p>If unfortunately, two maps have the same probability of appearance, the neurons will reach a <strong>consensus</strong>. It’s why <strong>attention is mandatory</strong>.</p><h3>Machine Intelligence</h3><p>Well, very great title. But, there is no intelligence in artificial intelligence. In the current methods used in AI, there is just an A.</p><blockquote>The future of AI will be based on principles that mimic the brain. p.117</blockquote><p>Why?</p><p>We, as Humans, <strong>learn continuously</strong>. Our brain <strong>updates</strong> its world model every second. The actual neural networks need to be fully trained once and have difficulties learning more things without losing too much information when retrained (called <strong>catastrophic forgetting</strong>[2]). A new domain called <strong>Continual Lifelong Learning</strong>[3][4] uses a continuous stream of data to train a neural network without losing information.</p><p>But why isn’t an I? It’s because today systems are specialized to do one thing, while humans could do multiple things. The AI is not <strong>flexible</strong>.</p><p>Currently, AI researchers couldn’t program a system that approaches the intelligence of a <strong>five-year-old child</strong>. They haven’t, yet, find a way to create the <strong><em>everyday knowledge</em></strong>. This problem is called <strong>knowledge representation</strong>, and it’s considered the <em>only problem</em>.</p><p>The brain learns a <strong>model of knowledge</strong>, not words or images. Like we have seen in the first part, the brain learns <strong>map-like references frames</strong>.</p><p>So how to consider a system as intelligent? What are the criteria?</p><p>The author provides <strong>four criteria to form the basis</strong> of machine intelligence.</p><ol><li>The machine needs to <strong>learn continuously</strong> (Continual Lifelong Learning). The machine needs to learn from its mistakes to update its world model. The machine needs to create new connections to acquire new knowledge without replacing old ones or delete them.</li><li>The machine will need to <strong>learn via movement</strong> (called embodiment). The motion leads to location. The world representation will be biased if it is avoided.</li><li>The machine needs to create many models. Each cortical column of the neocortex learns a model of thousand objects, and the process to resolve the binding problem (one unique perception) is made by <strong>voting. </strong>A machine needs to acquire the same process.</li><li>The machine needs to use reference frames to store knowledge. Thinking is a sort of movement. It is appeared by connecting the dots in the reference frames. If a machine can’t use motion, it cannot think.<br>Cortical columns use cells like grid cells and place cells.</li></ol><p><strong>When machines are conscious</strong></p><p>Consciousness depends on continuously forming memories of our recent thoughts and experiences and the ability to playing them back.</p><p><strong>Awareness</strong> seems to be intricate with <strong>consciousness. </strong>Memories and attention are the basis of consciousness. If I remember what I’ve been doing yesterday, and replace each moment. I’m aware of them, and I’m conscious.</p><p>A machine intelligence needs <strong>goals and motivations</strong>. But, they appear according to different procedures, encoded in the machine (our DNA programs our body to eat, breathe etc .). Or they are learned. They also need <strong>safety measures</strong>. For us, a safety measure is an impossibility of dying just by holding your breath. For a machine, the <strong>three laws of robotics</strong> by Isaac Asimov[5] could be a good start. <br>Goals and motivations are not a consequence of intelligence, and will not appear on their own.</p><h3>Conclusion</h3><p>The cons of the neocortex: every neuron is wired, so if a zone isn’t active at the beginning (young age), it will never be active. It’s why kids that heard many languages when they are young have more chance to be fluent in multiple languages when adult. The goal is to avoid this mechanism in a machine.</p><p>The author doesn’t talk about quantum processes or quantum phenomenons that are present in the brain (chemical processes or the teleportation of information).</p><p>The appearance of more and more powerful quantum computers will probably change how we think about the brain.</p><p>Last words, it’s a great book that I recommend to everyone. It gives a new perspective on the neocortex and how we learn. The approach of the author is very interesting and rises ideas and questions all along.</p><p>What I appreciate even more is that the author proposes his vision, his theory without criticizing those already present. Even when he discusses intelligent machines, he only points out the limits already established.</p><h3>References</h3><ul><li>[1] Mountcastle, Vernon, 1978. <em>An Organizing Principle for Cerebral Function The Unit Model and the Distributed System</em>. The Mindful Brain, 7–50. Cambridge, MA — MIT Press. <a href="http://nicorg.pbworks.com/w/file/fetch/49365852/Mountcastle%20Organizing%20Principle.pdf">http://nicorg.pbworks.com/w/file/fetch/49365852/Mountcastle%20Organizing%20Principle.pdf</a></li><li>[2] Michael McCloskey, Neal J. Cohen, 1989. <em>Catastrophic Interference in Connectionist Networks: The Sequential Learning Problem. </em>Psychology of Learning and Motivation, Academic Press, Volume 24, p.109–165. <a href="https://doi.org/10.1016/S0079-7421(08)60536-8">https://doi.org/10.1016/S0079-7421(08)60536-8</a></li><li>[3] James Kirkpatrick and al., 2016. <em>Overcoming catastrophic forgetting in neural networks</em>. ArXiv. <a href="http://arxiv.org/abs/1612.00796">http://arxiv.org/abs/1612.00796</a></li><li>[4] German I. Parisi et al., 2019. <em>Continual lifelong learning with neural networks: A review</em>. Neural Networks, Volume 113, p.54–71. <a href="https://doi.org/10.1016/j.neunet.2019.01.012">https://doi.org/10.1016/j.neunet.2019.01.012</a></li><li>[5] <a href="https://en.wikipedia.org/wiki/Three_Laws_of_Robotics">https://en.wikipedia.org/wiki/Three_Laws_of_Robotics</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ea6bbeeced0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/a-thousand-brains-theory-a-review-3ea6bbeeced0">A Thousand Brains Theory: A Review</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data representation in NLP]]></title>
            <link>https://medium.com/data-science/data-representation-in-nlp-cc9460f855a7?source=rss-9cf1f3f55c40------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc9460f855a7</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-representation]]></category>
            <dc:creator><![CDATA[Christophe Pere]]></dc:creator>
            <pubDate>Wed, 10 Feb 2021 19:38:00 GMT</pubDate>
            <atom:updated>2021-02-10T21:34:34.288Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*mj9_sbG3NOk0qFlsBSdgng.jpeg" /><figcaption>Source: Image taken by the author</figcaption></figure><h4>A theoretical way through <em>n-grams</em>, <em>tf-idf</em>, one-hot encoding, word embeddings. And a surprise with pre-trained models.</h4><h4>Introduction</h4><blockquote>Natural Language Processing seeks to map language to representations that capture morphological, lexical, syntactic, semantic, or discourse characteristics that can be processed by machine learning methods.</blockquote><blockquote>Kamath, J. Liu, and Whitake 2019</blockquote><p>It is necessary to present elements of theory before entering the algorithmic methodology. Many current methods are based on fundamentals that are easy to forget because their use is not direct.</p><p>This section will present classic NLP methods such as N-grams (Broder et al. 1997), tf-idf (Luhn 1957; Jones 1972), One-Hot encoding (D. Harris and S. Harris 2012), and words embeddings (Firth 1957; Gerard Salton 1962; G. Salton, Wong, and Yang 1975; Bengio et al. 2003; Mikolov, Sutskever, Chen, G. Corrado, et al. 2013). The last sub-section will deal with pre-trained models, particularly present since the advent of transformers (Vaswani et al. 2017).</p><h4>N-grams</h4><p>The n-grams refer to the granularity of the cut of a text. When the text is cut in the form of tokens it is made in unigram of the assemblages of a single word. When the text is cut into several words, two, for example, this is called bigrams, etc.</p><p><strong>Example</strong>:</p><p>Sentence: « I am an AI researcher trying to explain NLP concepts of data representation»</p><ul><li><strong>Unigram:</strong> (I), (am), (an), (AI), (researcher), (trying), (to), (explain), (NLP), (concepts), (of), (data), (representation)</li><li><strong>Bigram or 2-grams: (</strong>I, am), (am, an), (an, AI), (AI, researcher), (researcher, trying), (trying, to), (to, explain), (explain, NLP), (NLP, concepts), (concepts, of), (of, data), (data, representation)</li><li><strong>Trigram or 3-grams:</strong> (I, am, an), (am, an, AI), (an, AI, researcher), (AI, researcher, trying), (researcher, trying, to), (trying, to, explain), (to, explain, NLP), (explain, NLP, concepts), (NLP, concepts, of), (concepts, of, data), (of, data, representation)</li></ul><p>Each of these n-grams is assigned a probability of existence <strong>P(w|h)</strong> where <strong><em>w</em></strong><em> </em>is the next word and <strong><em>h </em></strong>the history (this is the number of times <strong><em>w </em></strong>is present in the corpus).</p><p>If <strong>P(the|this water is so transparent that)</strong> either the probability that <strong><em>the </em></strong>is the next word in the sentence <strong><em>this water is so transparent that</em></strong> one would have to calculate the number of times that <strong><em>w </em></strong>follows <strong><em>h </em></strong>divided by <strong><em>h</em></strong>. Eq. 1 shows the calculation of this probability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*t4xH9UsFiSq1-WkDebCNOw.png" /><figcaption>Eq. 1 Probability of the next word</figcaption></figure><p>The problem comes from the size of the corpus needed to count each occurrence and each possible variation. The history <strong><em>h </em></strong>is a set of <strong><em>N </em></strong>words that can be noted <strong><em>w_1;w_2;w_3;…;w_N</em></strong>. The associated probability is thus written <strong>P(w_1;w_2;w_3;…;w_N)</strong>. To calculate this probability we must use the<em> chain probability laws</em> (Eq. 2: the joint probabilities).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*oT_OoUVQ5hAZnfKHydVIeA.png" /><figcaption>Eq.2 Joint Probabilities</figcaption></figure><p>To reduce the calculation time, it is necessary to reduce this probability (approximation) to the previous few words.</p><p>For a bigram, the probability is reduced to <strong>P(w|h) ~= P(w|w_1)</strong> where <em>w_1 </em>is the previous word <em>w</em>, i.e.:</p><p><strong>P(the|this water is so transparent that) ~= P(the|this)</strong></p><p>Eq. 3 presents the generalization of this case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/213/1*ogZGYGDXL_EvrM-TUzwXkg.png" /><figcaption>Eq.3</figcaption></figure><p>The hypothesis that the probability of a bigram is based on the previous word is called the <strong>Markov hypothesis</strong> or <strong>Markov process</strong>. Markov models are a class of <strong>probabilistic models</strong> that allow us to predict events or words without having to rely on a large history.</p><p>A bigram model will be based on the previous word, a trigram model on the two previous words, and so on. The generalization to N-gram gives models based on <strong>N-1</strong> previous words.</p><p>Eq. 4 represents this probability:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*UWkgv10BIMS5HBFAMH1MZA.png" /><figcaption>Eq.4</figcaption></figure><p>The difference between equations 2 and 3 is shown by Eq. 5</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/199/1*AvnhHNRcFSJ324DvoBEKMQ.png" /><figcaption>Eq.5</figcaption></figure><p>The way to approach this probability is to use the <strong>maximum likelihood estimation</strong> (MLE) method (Stigler 2007). The principle is to count the occurrences in the corpus and normalize between 0 and 1.</p><p>In the case of the bigram, we can write Eq.6.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/233/1*WAjcp4xrckNUCVTpsXf7tw.png" /><figcaption>Eq.6</figcaption></figure><p>The common — but not trivial — simplification of this equation, as mentioned in (Daniel Jurafsky and J. H. Martin 2009; Daniel Jurafsky and J. H. Martin 2020), is that <strong>the sum of the number of bigrams </strong>beginning with the word <strong><em>w_n-1</em></strong> can be replaced by <strong>the number of unigrams of the word</strong> <strong><em>w_n-1</em></strong> (Eq. 7).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/208/1*DEE1j22F2EpfJsEcplXWbw.png" /><figcaption>Eq.7</figcaption></figure><p>Eq. 7 can be generalized to N-grams with the same hypothesis (MLE approach) as in the case of bigrams. The simplification is the replacement of the sum of occurrences by the number of occurrences of the N-gram (Eq. 8).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*3vHEql_8SAj0SCy09kbq4g.png" /><figcaption>Eq.8</figcaption></figure><p>Eq. 8 is called the <strong>relative frequency of a sequence through a corpus</strong>.</p><p>The main point to remember is that the higher the N-gram sequence is, the larger the corpus size must be. The sequence is <strong>reduced </strong>thanks to <strong>chain or join probabilities</strong>. The count is approximated by the <strong>sum of the N-grams</strong> found in the corpus.</p><h4>TF-IDF</h4><p>Term Frequency (TF). One way to begin a study in NLP is to convert the text, unstructured data, into a collection of words (tokens) — a “bag of words” or “BoW” (Z. S. Harris 1954). The words are thus independent in this assembly — this bag — and can be counted to determine their frequency of occurrence (Term Frequency — TF) called weight. Frequent words such as articles or linking terms have a strong recurrence in documents, which polishes the TF. A simple approach is to remove these so-called “meaningless” stopwords. It is generally preferable (Eq.9) to normalize word weights by the sum of the words in the document.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/120/1*nGI7ZebRb7Wk7JI4PYg5mQ.png" /><figcaption>Eq.9</figcaption></figure><p>Where n_ij represents the word whose TF is to be estimated and</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/45/1*2zgGLnKLY8QSDFp0eq1dCg.png" /></figure><p>the sum of the words in document k.</p><p><strong>Inverse Document Frequency (IDF)</strong>. The second step is to calculate a term called the Inverse Document Frequency (IDF). Eq. 10 is used to calculate it. It is a logarithm (base 10) of the ratio between the number N of documents and the number of documents in the corpus where the term <strong><em>df_i</em></strong><em> </em>is present. In other words, the IDF determines the weight of rare words in all the documents of the corpus.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/146/1*HfwxYt0mpDFYRJT5YBnl0A.png" /><figcaption>Eq.10</figcaption></figure><p>TF-IDF. The multiplication of Eq. 9 and Eq. 10 allows us to obtain the Term-Frequency-Inverse-Document-Frequency (TF-IDF) and it is shown in Eq. 11.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/177/1*Rx7brH4Pquz0SYCVseA2gQ.png" /><figcaption>Eq.11</figcaption></figure><p>Eq. 11 can be rewritten replacing the term <strong><em>tf_i,j</em></strong> by the ratio of Eq. 9. The result is presented in Eq.12.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/195/1*phw8bj71Zkbca08MfUM2iA.png" /><figcaption>Eq.12</figcaption></figure><p>The IDF part is very important because it allows correcting spelling mistakes. In general, if a word is misspelled like “exaple” rather than “example” its importance is the same as the well-spelled word. The TF-IDF corrects these errors because misspelled words have a very low coefficient.</p><h4>One-hot Encoding</h4><p>Another way to represent text for a machine is to create a matrix called “<strong>One-Hot encoding</strong>” (D. Harris and S. Harris 2012; Chollet 2017). This method is a binary representation of the information, of each word. It is necessary to create a vector containing the unique word of the corpus. Then, at each word of the text the vector will be filled with 0 except at the position where the word is located in the word vector. Thus, we create a matrix of <strong><em>n x m</em></strong> where <strong><em>n </em></strong>is the number of unique words and <strong><em>m </em></strong>is the number of words in the sentence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*LGpC1VcPYeZ-LC3PqZQtOA.png" /><figcaption>Fig.1: Representation of the transition from labeled data to a One-Hot encoding representation (Chollet 2017)</figcaption></figure><p>Fig. 1 shows the transformation between a label encoding matrix and the One-Hot Encoding transformation. The data in the Food Name column are projected in features (columns) whose content is a vector containing 0s and a 1 when the index corresponds to the feature. However, this method has some disadvantages:</p><ul><li>Large vector: The size of the vector is the number of unique words in the corpus or the number of most important words in the corpus (example: the 10,000 most important words).</li><li>Little information in vectors: Vectors are vectors containing only 0s and a 1 where the index corresponds to the considered word (sparse vector).</li><li>Raw representation: Vectors do not depend on machine learning performed on the data.</li><li>Absence of context: Each vector contains only the information of the considered word, this word is the only information contained in the vector which is therefore independent of the context and the meaning of the word in the context.</li><li>Memory size: Storing such a matrix in random access memory (RAM) may become impossible to contain.</li></ul><h4>Word vectors</h4><p>The last representation is called word vectors or word embeddings. This representation comes from research on the very structure of languages (Z. S. Harris 1954) and was popularized through the phrase “<em>you shall know a word by the company it keeps</em>” (Firth 1957). From that time on, intuition led to the idea that similar words should have their vector representation projected in an n-dimensional vector space (where n is an arbitrary number of contextual words) very close to each other.</p><p>Word embeddings are the representation or projection of a word in a multi-dimensional space as a vector of real (decimal) values. This multi-dimensional space contains specific words from which similarities are calculated (Table 1). The dimension of a word embeddings depends on the dimension of the multi-dimensional space. The number of dimensions is usually set to 300. This multi-dimensional space is small compared to the dimension of the matrices of One-Hot Encoding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*02Bi6mcTOxEx-SJpeikhag.png" /><figcaption>Table 1: Word embeddings representation. The space of dimension n has the value 300¹.</figcaption></figure><p>Table 1 shows the construction of word vectors. The index consists of words (300) with which a feature similarity value will be calculated. For example, the Gender index gives the value 1 for Man, -1 for Woman, -0.95 for King, 0.97 for Queen which are close and opposite values to contextualize gender. The words Apple and Orange have values of 0 because these words are not gendered.</p><p>In this way, each feature will obtain measures of similarity with the chosen index which will give a vector of decimal values or a vector of compressed information (compared to the One-Hot Encoding matrix).</p><p>This small dimension volume allows estimating values on a more restricted context in order not to generate zero probabilities for new word combinations. Similar work has been carried out on trigrams (Jelinek and Mercer 1980; Katz 1987) to demonstrate the relevance of a smaller context without granularity.</p><p>The feature vector or word vector represents different aspects of the word associated with a vector space. The probability function is expressed as the product of the conditional probabilities of the next word based on the previous ones. They are obtained via neural network algorithms by maximizing the cost function called log-likelihood (Vail, Valavanis, and Conrad 1959; Box and Jenkins 1976).</p><p>Word vectors are thus computed or “learned” from the data in a given corpus (Bengio et al. 2003). Word embeddings are dense vectors, unlike One-Hot Encoding (sparse vector — mostly made up of 0) (Rong 2016; Chollet 2017).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*uvu1_FEYFJf2WlUuQsp1Vw.png" /><figcaption>Fig.2: Comparison of One-Hot Encoding Matrix representations and word embeddings (Chollet 2017)</figcaption></figure><p>Fig. 2 shows the difference in the representation of the two previous approaches. This visualization allows understanding the dense aspect of word embeddings.</p><p>This representation of words as vectors also allows applying mathematical operators. For example, word embeddings can add and subtract — the canonical English example is given by Eq. 13 (Turney 2006; Vylomova et al. 2016).</p><blockquote>king-man + woman = queen (Eq.13)</blockquote><p>This operation is an example of the more general operation A : B :: C :? (Turney 2006) which shows that the context of a vector via a simple mathematical operation allows predicting the next word. In practice, word embeddings are calculated for each application because each use case differs from another. It is therefore necessary to adapt the neural network layer that will calculate the weights of dense vectors (the layer is called Embedding).</p><p>However, word embeddings have a strong constraint. It is the bias. Bolukbasi et al. 2016 demonstrate in their article that a natural bias is present. The discrimination would be present in the calculation of similarity between each word and could bias the models according to trends. These biases are native biases present in the texts (corpus) on which the models are pre-trained (Garg et al. 2018; Brunet et al. 2019; Zhao et al. 2019; Kumar et al. 2020; Papakyriakopoulos et al. 2020).</p><h4>Pre-trained models or language models</h4><p><strong>Before attention mechanisms </strong>(Graves, Wayne, and Danihelka 2014) The pre-trained models were developed to overcome the problem of low data volumes (or generalization). When the volume of data is low to very low (a few documents to a few dozen) the model cannot learn enough from the data to generate its own (accurate) word embeddings. It is therefore possible to use pre-trained models whose word vectors have been computed on a large corpus (several Giga or even terabytes of data). These large corpora allow computing Language Models, generalist pre-trained models that contain enough characteristics (parameters) to be able to infer the structures and representativeness of words.</p><p>These pre-trained models are generally calculated using the co-occurrence method (determination of the number of word associations in sequences) (Bengio et al. 2003). The best known pre-trained models used in research and industry are:</p><ul><li><strong>Word2vec</strong> (2013) (Mikolov, Chen, et al. 2013; Mikolov, Sutskever, Chen, G. S. Corrado, et al. 2013; Mikolov, Yih, and Zweig 2013),</li><li><strong>GloVe</strong> (2014) (Pennington, Socher, and C. Manning 2014),</li><li><strong>fastText</strong> (2016) (Joulin, Grave, Bojanowski, Douze, et al. 2016; Joulin, Grave, Bojanowski, and Mikolov 2016; Bojanowski et al. 2017)</li><li><strong>ELMo</strong> (2018) (Joshi, Peters, and Hopkins 2018; Peters et al. 2018)</li></ul><p>Less well-known models with performance comparable to attention mechanisms are ULMFit (Howard and Ruder 2018 — can be trained with documents in different languages) and MultiFit (Eisenschlos et al. 2020 — multilingual version of ULMFit). Both models have architectures made from memory models called Long Short Term Memory (LSTM — Hochreiter and Schmidhuber 1997).</p><p><strong>After attention mechanisms²³</strong>. The origin of the attention process comes from Graves, Wayne, and Danihelka (2014) in the article Neural Turing Machine. The goal of these mechanisms is to reproduce the functioning of the human brain when confronted with information, whether visual, sound, or written. The brain does not focus on the whole image, sound, or written information. It focuses on certain areas, the attention mechanisms are based on this principle.</p><p>Bahdanau, Cho, and Bengio (2016) have implemented attention mechanisms to compensate for the rigidity of the so-called <strong><em>seq2seq </em></strong>models (Sutskever, Vinyals, and Q. V. 2014), which are based on<strong><em> encoder-decoder</em></strong> architectures (Rumelhart, G. E. Hinton, and R. J. Williams 1986; Lecun 1987; Bourlard and Kamp 1988; Geoffrey E. Hinton and Zemel 1993). These models consist of two combined neural networks. The first is used to deconstruct the input and store its primary information in the bottleneck layer, and the second is used to reconstruct the information to generate a simulated input. The problem with these methods comes from the <strong>bottleneck </strong>layer which is of fixed size in the architecture and does not allow the storage of information and dependencies over the long term (long sentence).</p><p>There are three types of attention mechanisms. The first <strong><em>Self-Attention</em></strong> Cheng, Dong, and Lapata 2016 (also called <strong><em>Intra-Attention</em></strong>) focus on a part of the sentence at each step to obtain an overall representation of the same sentence. Next comes <strong><em>Soft Attention</em></strong> (Bahdanau, Cho, and Bengio 2016; K. Xu et al. 2016), their goal is to be able to encode the entire sentence or image in place. The advantage is that the model is simple and differentiable but very expensive in terms of calculations.</p><p><strong><em>Hard Attention</em></strong> (Luong, Pham, and C. D. Manning 2015; K. Xu et al. 2016) allows using only a portion of the sentence or image, which are called patches. The advantage is that only <strong>part of the information is used</strong>, so the inference time is reduced. However, due to this locality, models must use more combinations of techniques to be trained because the model is indistinguishable.</p><p>There is also two other methods <strong>Global and Local Attention</strong>. Global has the same behavior as Soft but local makes the Hard method differentiable.</p><p>In 2017 appear the <strong>Transformers </strong>(Vaswani et al. 2017) which are an improvement of the Soft approach and allow to do <em>seq2seq </em>without <strong>RNN</strong>. This architecture is called <strong>Self-Attention</strong> without alignment of sequences in an RNN. Based on Transformers, the <strong>multi-head Attention</strong> mechanism also appears. This approach makes it possible to create several attention mechanisms in parallel and to concatenate all the outputs linearly, like a so-called <strong>ensemble </strong>model. The goal is that each Head can focus on a sub-space of attention to increase the accuracy of the model.</p><p>A non-exhaustive list of pre-trained models based on transformers:</p><ul><li><strong>Bert</strong> (2018) (Devlin <em>et al.</em> 2018)</li><li><strong>GPT-2</strong> (2019) (Radford et al. 2019)</li><li><strong>Multi-lingual Bert</strong>⁴ (2019) (Pires, Schlinger, and Garrette 2019)</li><li><strong>RoBertA </strong>(2019) (Y. Liu <em>et al.</em> 2019)</li><li><strong>Multi-lingual XLM</strong> (2019) (Lample and Conneau 2019)</li><li><strong>FlauBert </strong>(V1–2019) (H. Le et al. 2020)</li><li><strong>Camembert </strong>(2020) (L. Martin et al. 2020)</li><li><strong>XLM-R</strong> (2020) (Conneau et al. 2020)</li><li><strong>XTREME</strong>⁴ (2020) (Hu et al. 2020)</li><li><strong>GPT-3</strong> (2020) (Brown et al. 2020)</li><li><strong>Switch Transformers</strong> (2021) (Fedus, Zoph, and Shazeer 2021)</li></ul><p>An accurate list of models can be found on <a href="https://huggingface.co/">huggingface</a>. The problem of the Transformers is the very low learning process and inference time. To correct this, different architectures have been released since 2017: LongFormers (Beltagy, M. E. Peters, and Cohan 2020), Fastformers (Kim and Awadalla 2020), Reformers (Kitaev, Kaiser, and Levskaya 2020), Big Bird (Zaheer et al. 2021).</p><h4>Conclusion</h4><p>Through this article, we reviewed different approaches for data representation in the NLP world. I also introduced the pre-trained models which are very useful when you have low data or to obtain more accurate models. The actual dominant of the NLP environment is the attention mechanism approach, in the appearance of Transformers architecture. The most known and used pre-trained model is BERT which is used in everyday life besides the google search engine. But, a lot of debates and recommendations, and petitions are written to prevent the use of very big pre-trained language model as GPT-3 or now Switch Transformers (trillions of parameters). An important wave in the AI world was about the article of Timnit Gebru about the danger of using big language models.</p><h4>References</h4><p>¹ Table presented by Andrew Ng during the online course (MOOC) <a href="https://www.coursera.org/lecture/nlp-sequence-models/word-representation-6Oq70">Deep Learning Specialization for the Word Representation </a>— Natural Language Processing &amp; Word Embeddings part on the Coursera platform.<br>² Lilian Weng provides an excellent survey on the blog “<a href="https://lilianweng.github.io/lil-log/2018/06/24/attention-attention.html">Lil’Log</a>” and the <a href="https://lilianweng.github.io/lil-log/2020/04/07/the-transformer-family.html">second article</a><br>³ Another resource is the blog of Jay Alammar <a href="http://jalammar.github.io/illustrated-transformer/"><em>The Illustrated Transformer</em></a><br>⁴ <a href="https://ai.googleblog.com/2020/08/language-agnostic-bert-sentence.html">https://ai.googleblog.com/2020/08/language-agnostic-bert-sentence.html</a><br>⁵ <a href="https://ai.googleblog.com/2020/04/xtreme-massively-multilingual-multi.html">https://ai.googleblog.com/2020/04/xtreme-massively-multilingual-multi.html</a></p><p><strong>Articles</strong></p><ul><li>Bahdanau, Dzmitry, Kyunghyun Cho, and Yoshua Bengio(2016). <em>Neural Machine Translation by Jointly Learning to Align and Translate</em>. arXiv:<a href="https://arxiv.org/abs/1409.0473">1409.0473</a></li><li>Beltagy, Iz, Matthew E. Peters, and Arman Cohan (2020). <em>Longformer: The Long-Document Transformer</em>. <a href="https://arxiv.org/abs/2004.05150">arXiv:2004.05150</a></li><li>Bengio, Yoshua et al. (Mar. 2003). “<em>A Neural Probabilistic Language Model</em>”. In: J. Mach. Learn. Res.3, pp. 1137–1155.ISSN: 1532–4435.</li><li>Bojanowski, Piotr et al. (2017). “<em>Enriching Word Vectors with Subword Information</em>”. In: Transactions of theAssociation for Computational Linguistics5, pp. 135–146</li><li>Bolukbasi, Tolga et al. (2016). “<em>Man is to Computer Programmer as Woman is to Homemaker? Debiasing WordEmbeddings</em>”. In: Proceedings of the 30th International Conference on Neural Information Processing Systems. NIPS’16. Barcelona, Spain: Curran Associates Inc., pp. 4356–4364. ISBN: 9781510838819.</li><li>Bourlard, H. and Y. Kamp (Sept. 1988). “<em>Auto-Association by Multilayer Perceptrons and Singular Value Decomposition</em>”. In: Biol. Cybern.59.4–5, pp. 291–294.ISSN:0340–1200.</li><li>Box, George. E.P. and Gwilym M. Jenkins (1976). <em>TimeSeries Analysis: Forecasting and Control</em>. Holden-Day.</li><li>Broder, Andrei Z. et al. (1997). “<em>Syntactic clustering of the Web</em>”. In: Computer Networks and ISDN Systems 29.8. Papers from the Sixth International World Wide Web Conference, pp. 1157–1166. ISSN: 0169–7552.</li><li>Brown, Tom B. et al. (2020). <em>Language Models are Few-Shot Learners</em>. <a href="https://arxiv.org/abs/2005.14165">arXiv:2005.14165</a></li><li>Brunet, Marc-Etienne et al. (Sept. 2019). “<em>Understanding the Origins of Bias in Word Embeddings</em>”. In: ed. by Kamalika Chaudhuri and Ruslan Salakhutdinov.Vol. 97. Proceedings of Machine Learning Research.Long Beach, California, USA: PMLR, pp. 803–811.</li><li>Cheng, Jianpeng, Li Dong, and Mirella Lapata (2016). <em>Long Short-Term Memory-Networks for Machine Reading</em>. <a href="https://arxiv.org/abs/1601.06733">arXiv:1601.06733</a></li><li>Chollet, Francois (2017). <em>Deep Learning with Python</em>. 1st.USA: Manning Publications Co.ISBN: 1617294438</li><li>Conneau, Alexis et al. (2020). <em>Unsupervised Cross-lingual Representation Learning at Scale</em>.<a href="https://arxiv.org/abs/1911.02116"> arXiv:1911.02116</a></li><li>Devlin, Jacob et al. (2019). <em>BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding</em>. <a href="https://arxiv.org/abs/1810.04805">arXiv:1810.04805</a></li><li>Eisenschlos, Julian Martin et al. (2020). <em>MultiFiT: Efficient Multi-lingual Language Model Fine-tuning</em>. <a href="https://arxiv.org/abs/1909.04761">arXiv:1909.</a>04761</li><li>Fedus, William, Barret Zoph, and Noam Shazeer (2021). <em>Switch Transformers: Scaling to Trillion ParameterModels with Simple and Efficient Sparsity</em>. arXiv:2101.03961 [cs.LG].</li><li>Firth, J.R. (1957). <em>A Synopsis of Linguistic Theory</em>, 1930–1955.URL:https://books.google.ca/books?id=T8LDtgAACAAJ.</li><li>Garg, Nikhil et al. (2018). “<em>Word embeddings quantify 100 years of gender and ethnic stereotypes</em>”. In:Proceedings of the National Academy of Sciences115.16,E3635–E3644.ISSN: 0027–8424.DOI:10.1073/pnas.1720347115. eprint:https : / / www . pnas . org /content/115/16/E3635.full.pdf.URL:https://www.pnas.org/content/115/16/E3635.</li><li>Graves, Alex, Greg Wayne, and Ivo Danihelka (2014). <em>Neural Turing Machines</em>. arXiv:1410.5401 [cs.NE].</li><li>Harris, D. and S. Harris (2012). <em>Digital Design and Computer Architecture</em>. Engineering professional collection.Elsevier Science.ISBN: 9780123944245.URL:https://books.google.ca/books?id=-DG18Nf7jLcC.</li><li>Harris, Zellig S. (1954). “<em>Distributional Structure</em>”. In:WORD10.2–3, pp. 146–162.DOI:10.1080/00437956.1954 . 11659520. eprint:https : / / doi . org / 10 .1080/00437956.1954.11659520.URL:https://doi.org/10.1080/00437956.1954.11659520.</li><li>Hinton, Geoffrey E. and Richard S. Zemel (1993). “<em>Autoen-coders, Minimum Description Length, and Helmholtz Free Energy</em>”. In: Proceedings of the 6th International Conference on Neural Information Processing Systems.NIPS’93. Denver, Colorado: Morgan Kaufmann Pub-lishers Inc., pp. 3–10.</li><li>Hochreiter, Sepp and Jürgen Schmidhuber (1997). “<em>Long-short-term memory</em>”. In: Neural computation9.8,pp. 1735–1780.</li><li>Howard, Jeremy and Sebastian Ruder (2018). <em>Universal Language Model Fine-tuning for Text Classification</em>.arXiv:1801.06146 [cs.CL].</li><li>Hu, Junjie et al. (2020). <em>XTREME: A Massively Multilingual Multi-task Benchmark for Evaluating Cross-lingualGeneralization</em>. arXiv:2003.11080 [cs.CL].</li><li>Jelinek, Fred and Robert L. Mercer (1980). “<em>Interpolated estimation of Markov source parameters from sparse data</em>”. In: Proceedings, Workshop on Pattern Recognition in Practice. Ed. by Edzard S. Gelsema and Laveen N. Kanal. Amsterdam: North-Holland, pp. 381–397.</li><li>Jones, Karen Spärck (1972). “<em>A statistical interpretation of term specificity and its application in retrieval</em>”. In: Journal of Documentation28, pp. 11–21.</li><li>Joshi, Vidur, Matthew Peters, and Mark Hopkins (2018). <em>Extending a Parser to Distant Domains Using a Few Dozen Partially Annotated Examples</em>. arXiv:1805 .06556 [cs.CL].</li><li>Joulin, Armand, Edouard Grave, Piotr Bojanowski, Matthijs Douze, et al. (Dec. 2016). “<em>FastText.zip: Com-pressing text classification models</em>”.</li><li>Joulin, Armand, Edouard Grave, Piotr Bojanowski, and Tomas Mikolov (2016). <em>Bag of Tricks for Efficient Text Classification</em>. arXiv:1607.01759 [cs.CL].</li><li>Jurafsky, Dan and James H. Martin (2020). <em>Speech and Language Processing</em> (3rd ed. draft). English (US).Stanford University website.URL:https : / / web .stanford . edu / ~jurafsky / slp3/(visited on11/03/2020).</li><li>Jurafsky, Daniel and James H. Martin (2009).<em> Speech and Language Processing</em> (2nd Edition). USA: Prentice-Hall, Inc.ISBN: 0131873210.</li><li>Kamath, U., J. Liu, and J. Whitaker (2019). <em>Deep Learning for NLP and Speech Recognition</em>. Springer International Publishing.ISBN: 9783030145965.URL:https://books.google.ca/books?id=8cmcDwAAQBAJ.</li><li>Kanis, Jakub and Lucie Skorkovská (2010). “<em>Comparison of Different Lemmatization Approaches through the Means of Information Retrieval Performance</em>”. In: Proceedings of the 13th International Conference on Text, Speech, and Dialogue. TSD’10. Brno, Czech Republic: Springer-Verlag, pp. 93–100.ISBN: 3642157599.</li><li>Katz, S. (1987). “<em>Estimation of probabilities from sparse data for the language model component of a speech recognizer</em>”. In: IEEE Transactions on Acoustics, Speech, and Signal Processing35.3, pp. 400–401.DOI:10 .1109/TASSP.1987.1165125.</li><li>Kim, Young Jin and Hany Hassan Awadalla (2020). <em>Fast-Formers: Highly Efficient Transformer Models for Natural Language Understanding</em>. arXiv:2010.13382[cs.CL].</li><li>Kitaev, Nikita, Łukasz Kaiser, and Anselm Levskaya(2020). <em>Reformer: The Efficient Transformer</em>. arXiv:2001.04451 [cs.LG].</li><li>Kumar, Vaibhav et al. (2020). <em>Nurse is Closer to Woman than Surgeon? Mitigating Gender-Biased Proximities in Word Embeddings</em>. arXiv:2006.01938 [cs.CL].</li><li>Lample, Guillaume, Miguel Ballesteros, et al. (2016).“<em>Neural Architectures for Named Entity Recognition</em>”.In:CoRRabs/1603.01360. arXiv:1603.01360.</li><li>Lample, Guillaume and Alexis Conneau (2019). <em>Cross-lingual Language Model Pretraining</em>. arXiv:1901 .07291 [cs.CL].</li><li>Le, Hang et al. (2020). <em>FlauBERT: Unsupervised Language Model Pre-training for French</em>. arXiv:1912 .05372 [cs.CL].</li><li>Lecun, Yann (June 1987).<em> PhD thesis: Modeles connexionnistes de l’apprentissage (connectionist learning models)</em>. English (US). Universite P. et M. Curie (Paris 6).</li><li>Liu, Yinhan et al. (2019). RoBERTa: A Robustly Optimized BERT Pretraining Approach. arXiv:1907.11692[cs.CL].</li><li>Luhn, H. P. (1957). “A Statistical Approach to Mechanized Encoding and Searching of Literary Information”. In:IBM Journal of Research and Development1.4, pp. 309–317.DOI:10.1147/rd.14.0309.</li><li>Luong, Minh-Thang, Hieu Pham, and Christopher D.Manning (2015).Effective Approaches to Attention-based Neural Machine Translation. arXiv:1508.04025[cs.CL].</li><li>Martin, Louis et al. (2020). “CamemBERT: a Tasty FrenchLanguage Model”. In:Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics.DOI:10.18653/v1/2020.acl-main.645.URL:http://dx.doi.org/10.18653/v1/2020.acl-main.645.</li><li>Mikolov, Tomas, Kai Chen, et al. (2013). Efficient Estimation of Word Representations in Vector Space. arXiv:1301.3781 [cs.CL].</li><li>Mikolov, Tomas, Ilya Sutskever, Kai Chen, Greg SCorrado, et al. (2013). “Distributed Representations of Words and Phrases and their Compositionality”.In: Advances in Neural Information Processing Systems. Ed. by C. J. C. Burges et al. Vol. 26. CurranAssociates, Inc., pp. 3111–3119.URL:https : / /proceedings.neurips.cc/paper/2013/file/9aa42b31882ec039965f3c4923ce901b — Paper .pdf.</li><li>Mikolov, Tomas, Ilya Sutskever, Kai Chen, Greg Corrado, et al. (2013).Distributed Representations of Words and Phrases and their Compositionality. arXiv:1310.4546[cs.CL].</li><li>Mikolov, Tomas, Wen-tau Yih, and Geoffrey Zweig (June 2013). “Linguistic Regularities in Continuous SpaceWord Representations”. In: Proceedings of the 2013 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies. Atlanta, Georgia: Association for Computational Linguistics, pp. 746–751.URL:https://www.aclweb.org/anthology/N13–1090.</li><li>Papakyriakopoulos, Orestis et al. (2020). “Bias in Word Embeddings”. In: Proceedings of the 2020 Conference on Fairness, Accountability, and Transparency. FAT*’20. Barcelona, Spain: Association for Computing Machinery, pp. 446–457.ISBN: 9781450369367.DOI:10.1145/3351095.3372843.URL:https://doi.org/10.1145/3351095.3372843.</li><li>Pennington, Jeffrey, Richard Socher, and Christopher Manning (Oct. 2014). “GloVe: Global Vectors for Word Representation”. In: Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing(EMNLP). Doha, Qatar: Association for ComputationalLinguistics, pp. 1532–1543.DOI:10.3115/v1/D14–1162.URL:https://www.aclweb.org/anthology/D14-1162.</li><li>Peters, Matthew et al. (June 2018). “Deep Contextualized Word Representations”. In: Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human LanguageTechnologies, Volume 1 (Long Papers). New Orleans, Louisiana: Association for Computational Linguistics,pp. 2227–2237.DOI:10.18653/v1/N18–1202.URL:https://www.aclweb.org/anthology/N18-1202.Pires, Telmo, Eva Schlinger, and Dan Garrette (2019).How multilingual is Multilingual BERT?arXiv:1906.01502[cs.CL].</li><li>Radford, Alec et al. (2019). “<em>Language Models are Unsupervised Multitask Learners</em>”.</li><li>Rong, Xin (2016). <em>word2vec Parameter Learning Explained</em>. arXiv:1411.2738 [cs.CL].</li><li>Rumelhart, D. E., G. E. Hinton, and R. J. Williams (1986).“<em>Learning Internal Representations by Error Propagation</em>”. In:Parallel Distributed Processing: Explorations in the Microstructure of Cognition, Vol. 1: Foundations.Cambridge, MA, USA: MIT Press, pp. 318–362.ISBN:026268053X.</li><li>Salton, G., A. Wong, and C. S. Yang (Nov. 1975). “A Vector Space Model for Automatic Indexing”. In:Commun. ACM18.11, pp. 613–620.ISSN: 0001–0782.DOI:10.1145/361219.361220.URL:https://doi.org/10.1145/361219.361220.</li><li>Salton, Gerard (1962). “<em>Some Experiments in the Generation of Word and Document Associations</em>”. In:Proceedings of the December 4–6, 1962, Fall Joint ComputerConference. AFIPS ’62 (Fall). Philadelphia, Pennsylvania: Association for Computing Machinery, pp. 234–250.ISBN: 9781450378796.DOI:10.1145/1461518.1461544.URL:https : / / doi . org / 10 . 1145 /1461518.1461544.</li><li>Stigler, Stephen M. (Nov. 2007). “<em>The Epic Story of Maxi-mum Likelihood</em>”. In: Statistical Science22.4, pp. 598–620.ISSN: 0883–4237.DOI:10.1214/07- sts249.URL:http://dx.doi.org/10.1214/07-STS249.</li><li>Sutskever, Ilya, Oriol Vinyals, and Quoc V. Le (2014). <em>Sequence to Sequence Learning with Neural Networks</em>.arXiv:1409.3215 [cs.CL].</li><li>Turney, Peter D. (Sept. 2006). “<em>Similarity of Semantic Relations</em>”. In:Computational Linguistics32.3, pp. 379–416.ISSN: 1530–9312.DOI:10.1162/coli.2006.32.3.379.URL:http://dx.doi.org/10.1162/coli.2006.32.3.379.</li><li>Vail, S.V., S. Valavanis, and A.H. Conrad (1959). <em>Econometrics: An Introduction to Maximum Likelihood Methods</em>. Economics handbook series. McGraw-Hill.URL:https://books.google.ca/books ? id =ZRcYAAAAIAAJ.</li><li>Vaswani, Ashish et al. (2017). <em>Attention Is All You Need</em>.arXiv:1706.03762 [cs.CL].</li><li>Vylomova, Ekaterina et al. (2016).<em> Take and Took, Gaggleand Goose, Book and Read: Evaluating the Utility of Vector Differences for Lexical Relation Learning</em>. arXiv:1509.01692 [cs.CL].</li><li>Xu, Kelvin et al. (2016). <em>Show, Attend and Tell: Neural Image Caption Generation with Visual Attention</em>. arXiv:1502.03044 [cs.LG].</li><li>Zaheer, Manzil et al. (2021). <em>Big Bird: Transformers for Longer Sequences</em>. arXiv:2007.14062 [cs.LG].</li><li>Zhao, Jieyu et al. (June 2019). “<em>Gender Bias in Contextualized Word Embeddings</em>”. In:Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers). Minneapolis, Minnesota: Association for ComputationalLinguistics, pp. 629–634.DOI:10.18653/v1/N19–1064.URL:https://www.aclweb.org/anthology/N19-1064.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc9460f855a7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/data-representation-in-nlp-cc9460f855a7">Data representation in NLP</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Learn Quantum Computing]]></title>
            <link>https://medium.com/swlh/how-i-learn-quantum-computing-bb22c9fdba12?source=rss-9cf1f3f55c40------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb22c9fdba12</guid>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Christophe Pere]]></dc:creator>
            <pubDate>Mon, 02 Nov 2020 16:09:21 GMT</pubDate>
            <atom:updated>2020-11-03T14:59:14.409Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b23UlquS_tIcsnXF5BZ-iA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@nasa?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">NASA</a> on <a href="https://unsplash.com/s/photos/science?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>A deep dive into the quantum world and AI</p><h4>Introduction</h4><p>I love quantum mechanics, something is fascinating about the perception of how QM explains the world. How different it is than the reality we can see and live in.</p><blockquote>Everything we call real is made of things that cannot be regarded as real.</blockquote><blockquote>Niels Bohr</blockquote><p>This quotation was a revelation to me when I was a student. Looking at the matter isn’t the good way because all of the elements are just waves. Why reality models itself when present to an observer?</p><blockquote><strong>I like to think</strong> the <strong>moon</strong> is there even <strong>if</strong> I am not <strong>looking</strong> at it. <br>Albert Einstein</blockquote><p>The debate between microscopic effects and macroscopic effects is also very exciting. Why the infinity small doesn’t act like the macroscopic world? Why my table is still here if I’m not looking at it? A lot of strange effects populate quantum mechanics and your conception of the world will change if you look closer to them.</p><blockquote>The way we have to describe Nature is generally incomprehensible to us. Richard Feynman.</blockquote><p>Richard Feynman described the fact Nature isn’t classical and to study it, we need a quantum computer. Here it is, the Revolution just born in the brain of an imminent physician.</p><p>When I speak about Quantum Computing (QC), I generally receive the same answers:</p><p><strong><em>Why? <br></em></strong>This <em>why </em>is more “why do we need to have an interest in QC?”. As you think, this question is from companies I worked with. Most of the time people are just afraid to change. And they prefer to ignore the possibility that what they actually know can be irrelevant in several years. So why QC? In terms of simulation, artificial intelligence, computation, optimization it’s just the future. We will soon break the frontier, the <a href="https://www.nature.com/articles/s41586-019-1666-5">quantum supremacy</a>, and prove that this technology allows us to reach the actual impossible (<em>to infinity and beyond</em> like my son loves to say).<a href="https://www.ibm.com/blogs/research/2020/09/ibm-quantum-roadmap/"> IBM has a plan to build a Quantum Computer with more than 1,000 qubits</a> (300 qubits represent 2³⁰⁰ states in superposition so more than atoms in the Universe, qubits is the name of the quantum bits used to compute) in 3 years. So the question is not why, but when? and How?</p><p><strong><em>The technology is not ready!<br></em></strong>I still laugh at this answer. The technology is not ready for what? <a href="https://www.dwavesys.com/our-company/meet-d-wave">D-Wave</a> builds QC since 1999, the latest release is a <a href="https://docs.dwavesys.com/docs/latest/c_gs_2.html">quantum annealer</a> with more than 5000 qubits. 1Qbit works with quantum solutions since 2012. IBM launched the IBM Q Experience in 2016 where you can use real QC in the cloud. Since, Microsoft via Azure launch his quantum platform, Google, Rigetti, etc. are also in the Cloud. So, the technology is here, but it depends on what you think. If it is “Can I have a QC at home?” the response is no for 99.999% of the population because the cost of a QC is around 10 million dollars. But, if the question is “Can I work and do research in real QC?” the answer is yes. If you ask “Can I have a QC to put applications in production?” the answer is, it depends.</p><p><strong><em>What are the advantages?</em></strong><br>They are many, but they are many disadvantages also. The advantages, you could compute 2^n (<em>n</em> is the number of qubits) states in superposition. Superposition allows you to compute 2^n computations at the same time, without looping into infinity. The problem is you need to understand interference to obtain and select the best results. The consumption of energy is constant, just need to refrigerate the qubits at almost absolute zero temperature to be stable. And many other things.</p><p><strong><em>Too complicated!</em></strong><br>I would say, if it’s easy it’s not interesting, we learn nothing. If you permit me a quotation of JFK when he speaks about the journey to the Moon:</p><blockquote>We choose to go to the Moon in this decade and do the other things, not because they are easy, but because they are hard, because that goal will serve to organize and measure the best of our energies and skills, because that challenge is one that we are willing to accept, one we are unwilling to postpone, and one which we intend to win, and the others, too. JFK</blockquote><p>For me, interesting things come with challenges. So is QC complicated? Yes and no, is it because it’s something new, it’s something for which we need to change our thinking. Is it really complicated? No, it’s like a new thing, you need to learn and apply.</p><p>Ok, It’s a big introduction, but how to learn what is a quantum computer and what is quantum computing?</p><h4>Formations</h4><p>I was lucky recently in this field and was accepted in a training provided by IBM and The Coding School. The formation is <a href="https://www.ibm.com/blogs/research/2020/10/quantum-coding-school/">Qubit by Qubit’s Introduction To Quantum Computing</a> and it’s provided between October 2020 and May 2021.</p><p>I was also accepted in the <a href="https://quantum-computing.ibm.com/challenges">IBM Quantum Challenge</a>, 3 weeks of intense formation on <a href="https://qiskit.org/textbook/content/ch-ex/">Qiskit</a>, and the <a href="https://www.ibm.com/quantum-computing/?p1=Search&amp;p4=43700050385922780&amp;p5=e&amp;cm_mmc=Search_Google-_-1S_1S-_-WW_NA-_-ibm%20quantum%20experience_e&amp;cm_mmca7=71700000061253574&amp;cm_mmca8=kwd-397733481108&amp;cm_mmca9=Cj0KCQjwlvT8BRDeARIsAACRFiXpHMV98TPnovz-a_-uHPq1_rwtVPs5fuVpsUB8gYYILKwqjk9VtHQaAoXeEALw_wcB&amp;cm_mmca10=427831691204&amp;cm_mmca11=e&amp;gclid=Cj0KCQjwlvT8BRDeARIsAACRFiXpHMV98TPnovz-a_-uHPq1_rwtVPs5fuVpsUB8gYYILKwqjk9VtHQaAoXeEALw_wcB&amp;gclsrc=aw.ds">IBM Quantum Experience</a>.</p><p>But before that, I was just a young passionate about the field and looking for textbooks, tutorials, etc. just exploring different resources and going forward.</p><h4>Resources</h4><p>But, without this, how to learn Quantum Computing? Several good resources are available.</p><p>You can find lots of resources on youtube, explaining every part or every block of quantum mechanics. You can find lots and lots of resources on the internet. I just provide here some that I think are more useful or I appreciated the most. We begin with YouTube channels:</p><p><strong>Videos</strong></p><ul><li><a href="https://www.youtube.com/qiskit">Qiskit</a>, Youtube</li><li><a href="https://qiskit.org/learn/intro-qc-qh/">Introduction to Quantum Computing and Quantum Hardware</a>, Qiskit</li><li><a href="https://www.youtube.com/watch?v=AUjFBC9XBjg&amp;t=4123s">Conference Quantum Computing Paris Saclay</a>, YouTube</li></ul><p>They are very interesting and the two first provided a very good introduction and useful information to study and use Qiskit, the IBM library to code Quantum Computers in Python. They are others like <a href="https://pennylane.ai/">Pennylane</a>, <a href="https://github.com/quantumlib/Cirq">Cirq</a>, <a href="https://www.tensorflow.org/quantum">TensorFlow-quantum </a>but, I let you explore these ways and give me feedback.</p><p><strong>Textbooks</strong></p><p>I love books, so for me, it is one of the best ways to acquire knowledge about something. There aren’t tons of books about quantum computing, so when you look at “best books” or “reading list” for quantum computing you reach globally the same books, there, I provide a list of my favorites:</p><ul><li><a href="https://www.packtpub.com/product/dancing-with-qubits/9781838827366">Dancing with Qubits</a>, Robert Sutor, 2019, Packt</li><li><a href="https://www.cambridge.org/core/books/quantum-computation-and-quantum-information/01E10196D0A682A6AEFFEA52D53BE9AE">Quantum Information and Quantum Computation, 10th anniversary, Nielsen and Chuand</a>, 2012, Cambridge University Press</li><li><a href="https://www.oreilly.com/library/view/programming-quantum-computers/9781492039679/">Programming Quantum Computing</a>, Jonhston et al. 2019, O’Reilly</li><li><a href="https://www.amazon.co.uk/Dance-Photons-Einstein-Quantum-Teleportation/dp/0374239665/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1524589007&amp;sr=1-1&amp;keywords=dance+of+the+photons">Dance of the Photons: From Einstein to Quantum Teleportation</a>, Anton Zeilinger, 2010</li><li><a href="https://www.amazon.co.uk/Quantum-Mechanics-Theoretical-Minimum-ebook/dp/B00IFTT8GA/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1524588975&amp;sr=1-1&amp;keywords=leonard+susskind+theoretical+minimum">Quantum Mechanics: The Theoretical Minimum</a>, Leonard Susskind &amp; Art Freidman, 2014</li><li><a href="https://www.springer.com/gp/book/9783030239213">Quantum Computing: An Applied Approach</a>, Jack D. Hidary, 2019</li></ul><p><strong>Blogs / Articles</strong></p><p>You also have very good resources through blogs and scientific papers. Here, are just a few:</p><ul><li><a href="https://quantum.country/qcvc">Quantum Computing for the Very Curious</a>, Andy Mathushak &amp; Micheal Nielsen</li><li><a href="https://qiskit.org/textbook/content/ch-ex/">Qiskit textbook</a>, IBM</li><li><a href="https://www.wired.com/story/wired-guide-to-quantum-computing/">Guide to Quantum Computing</a>, WIRED</li><li><a href="https://www.ibm.com/quantum-computing/learn/what-is-quantum-computing/">Quantum Computing</a>, IBM</li><li><a href="https://arxiv.org/abs/2006.02799">Quantum-Computation and Applications</a>, Bhupesh Bishnoi, 2020, arXiv preprint</li><li><a href="https://arxiv.org/abs/1907.09415">Quantum Computing: Lecture Notes</a>, Ronald de Wolf, 2019</li><li><a href="https://arxiv.org/abs/2005.03137">A Gentle Introduction to Quantum Computing Algorithms with Applications to Universal Prediction</a>, Elliot Catt and Marcus Hutter, 2020</li><li><a href="https://arxiv.org/abs/1810.08277">Quantum computing from a mathematical perspective: a description of the quantum circuit model</a>, J. Ossorio-Castillo and José M. Tornero, 2018</li><li><a href="https://lapastillaroja.net/wp-content/uploads/2016/09/Intro_to_QC_Vol_1_Loceff.pdf">A course in Quantum Computing</a>, Michael Loceff, 2015</li></ul><p><strong>MOOCs</strong></p><p>MOOCs in QC are not many. The technology is too young and there aren’t many resources to use easily. But, I found three relevant:</p><ul><li><a href="https://www.edx.org/learn/quantum-computing">Quantum Computing</a>, edx</li><li><a href="https://www.coursera.org/learn/quantum-computing-algorithms">The Introduction to Quantum Computing</a>, Coursera</li><li><a href="https://brilliant.org/courses/quantum-computing/">Quantum Computing</a>, Brilliant</li></ul><h4>Quantum Machine Learning</h4><p>Yeah, next frontier, Quantum Machine Learning, or QML. Quantum Computing masters the art of computation especially with superposition (relevant in optimization). The natural way led to the field of Artificial Intelligence with the domain of machine learning. This is why I learn QC. I want to use QC in my day to day work as an AI researcher. Few resources:</p><ul><li><a href="https://www.edx.org/course/quantum-machine-learning">Quantum Machine Learning</a>, edx</li><li><a href="http://dx.doi.org/10.1038/nature23474">Quantum machine learning</a>, Biamonte et al. 2017, Nature</li><li><a href="https://arxiv.org/abs/1707.08561v2?source=post_page---------------------------">Quantum Machine Learning: a classical perspective</a>, Ciliberto et al., 2017, arXiv preprint</li><li><a href="https://arxiv.org/abs/2006.12270">Classification with Quantum Machine Learning: A Survey</a>, Abohashima et al. 2020, arXiv preprint</li><li><a href="https://arxiv.org/abs/1804.10068">Quantum Machine Learning for Data Scientists</a>, Kopczyk, 2018, arXiv preprint</li><li><a href="https://arxiv.org/abs/2005.04316">Advances in Quantum Deep Learning: An Overview</a>, Garg &amp; Ramakrishnan, 2020, arXiv paper</li></ul><h4>GitHub repositories</h4><p>How to go deeper? Good question, I think the most interesting way is to practice and to look at Github repositories. Especially those entitled awesome-something.</p><ul><li><a href="https://github.com/krishnakumarsekar/awesome-quantum-machine-learning">Awesome Quantum Machine Learning</a>, krishnakumarsekar</li><li><a href="https://github.com/artix41/awesome-quantum-ml">Awesome Quantum ML</a>, artix41</li><li><a href="https://github.com/desireevl/awesome-quantum-computing">Awesome Quantum Computing</a>, desireevl</li></ul><h4>Conclusion</h4><p>Yeah, I know, lots of materials but, it’s a shortlist. Even if the domain is pretty young, the number of resources is growing exponentially. <strong>Quantum Computing is the new oil</strong>, <a href="https://medium.com/qiskit/why-were-on-a-mission-to-ensure-every-high-school-student-learns-quantum-computing-bdbda15e0dbd">IBM is on a crusade to teach QC to every student in high school</a>.</p><p>I’m always learning about QC because it will replace classical computing in different areas like chemistry, artificial intelligence, finance, optimization. I recently read that, the advice for companies was to hire a Quantum Computing officer to write the strategy of the migration. It is inevitable for the future of companies to avoid this technology. The number of quantum computers is only increasing and will soon make it possible to manage applications in production.</p><p>Many learners turn to this technology to learn the concepts and how to use them in order to be ready. Currently, most of the work of QC is at the research stage, but tomorrow will arrive very quickly. Don’t learn too late.</p><h4>References</h4><ul><li>Arute, F., Arya, K., Babbush, R. <em>et al.</em> Quantum supremacy using a programmable superconducting processor. <em>Nature</em> <strong>574, </strong>505–510 (2019). <a href="https://doi.org/10.1038/s41586-019-1666-5">https://doi.org/10.1038/s41586-019-1666-5</a> <a href="https://www.nature.com/articles/s41586-019-1666-5">https://www.nature.com/articles/s41586-019-1666-5</a></li><li><a href="https://www.ibm.com/blogs/research/2020/09/ibm-quantum-roadmap/">https://www.ibm.com/blogs/research/2020/09/ibm-quantum-roadmap/</a></li><li><a href="https://www.dwavesys.com/our-company/meet-d-wave">https://www.dwavesys.com/our-company/meet-d-wave</a></li><li><a href="https://www.ibm.com/blogs/research/2020/10/quantum-coding-school/">https://www.ibm.com/blogs/research/2020/10/quantum-coding-school/</a></li><li><a href="https://quantum-computing.ibm.com/challenges">https://quantum-computing.ibm.com/challenges</a></li><li><a href="https://qiskit.org/textbook/content/ch-ex/">https://qiskit.org/textbook/content/ch-ex/</a></li><li><a href="https://www.ibm.com/quantum-computing/?p1=Search&amp;p4=43700050385922780&amp;p5=e&amp;cm_mmc=Search_Google-_-1S_1S-_-WW_NA-_-ibm%20quantum%20experience_e&amp;cm_mmca7=71700000061253574&amp;cm_mmca8=kwd-397733481108&amp;cm_mmca9=Cj0KCQjwlvT8BRDeARIsAACRFiXpHMV98TPnovz-a_-uHPq1_rwtVPs5fuVpsUB8gYYILKwqjk9VtHQaAoXeEALw_wcB&amp;cm_mmca10=427831691204&amp;cm_mmca11=e&amp;gclid=Cj0KCQjwlvT8BRDeARIsAACRFiXpHMV98TPnovz-a_-uHPq1_rwtVPs5fuVpsUB8gYYILKwqjk9VtHQaAoXeEALw_wcB&amp;gclsrc=aw.ds">IBM Quantum Experience</a></li><li><a href="https://www.google.com/url?q=https://www.google.com/url?q%3Dhttps://www.wired.com/story/wired-guide-to-quantum-computing/%26amp;sa%3DD%26amp;ust%3D1604200789119000%26amp;usg%3DAOvVaw0vH1-Dj5MZWToyDs1MgSzg&amp;sa=D&amp;ust=1604200789141000&amp;usg=AOvVaw0rpIwDDP5whl1VAawMPZ0y">https://www.wired.com/story/wired-guide-to-quantum-computing/</a></li><li><a href="https://www.ibm.com/quantum-computing/learn/what-is-quantum-computing/">https://www.ibm.com/quantum-computing/learn/what-is-quantum-computing/</a></li><li><a href="https://www.youtube.com/qiskit">https://www.youtube.com/qiskit</a></li><li><a href="https://qiskit.org/learn/intro-qc-qh/">https://qiskit.org/learn/intro-qc-qh/</a></li><li><a href="https://www.packtpub.com/product/dancing-with-qubits/9781838827366">https://www.packtpub.com/product/dancing-with-qubits/9781838827366</a></li><li><a href="https://www.cambridge.org/core/books/quantum-computation-and-quantum-information/01E10196D0A682A6AEFFEA52D53BE9AE">https://www.cambridge.org/core/books/quantum-computation-and-quantum-information/01E10196D0A682A6AEFFEA52D53BE9AE</a></li><li><a href="https://www.springer.com/gp/book/9783030239213">https://www.springer.com/gp/book/9783030239213</a></li><li><a href="https://arxiv.org/abs/2006.02799">Bishnoi 2020, Quantum-Computation and Applications. ArXiv preprint</a></li><li><a href="https://arxiv.org/abs/1907.09415">de Wolf 2019, Quantum Computing: Lecture Notes. ArXiv preprint</a></li><li><a href="https://arxiv.org/abs/2005.03137">Catt and Hutter 2020, A Gentle Introduction to Quantum Computing Algorithms with Applications to Universal Prediction. ArXiv preprint</a></li><li><a href="https://arxiv.org/abs/1810.08277">Ossorio-Castillo &amp; Tornero 2018, Quantum computing from a mathematical perspective: a description of the quantum circuit model.ArXiv preprint</a></li><li><a href="https://www.edx.org/learn/quantum-computing">https://www.edx.org/learn/quantum-computing</a></li><li>Biamonte, J., Wittek, P., Pancotti, N. <em>et al.</em> Quantum machine learning. <em>Nature</em> <strong>549, </strong>195–202 (2017). <a href="https://doi.org/10.1038/nature23474">https://doi.org/10.1038/nature23474</a></li><li><a href="https://arxiv.org/abs/1707.08561v2?source=post_page---------------------------">Ciliberto et al. 2017, Quantum machine learning: a classical perspective. ArXiv preprint</a></li><li><a href="https://arxiv.org/abs/2006.12270">Abohashima et al. 2020, Classification with Quantum Machine Learning: A Survey. ArXiv preprint</a></li><li><a href="https://arxiv.org/abs/1804.10068">Kopczyk 2018, Quantum machine learning for data scientists. ArXiv preprint</a></li><li><a href="https://arxiv.org/abs/2005.04316">Garg &amp; Ramakrishnan 2020, Advances in Quantum Deep Learning: An Overview. ArXiv preprint</a></li><li><a href="https://arxiv.org/abs/2003.02989">Broughton et al. 2020, TensorFlow Quantum: A Software Framework for Quantum Machine Learning. ArXiv preprint</a></li><li><a href="https://arxiv.org/abs/1811.04968">Bergohlm et al. 2018, PennyLane: Automatic differentiation of hybrid quantum-classical computations. ArXiv preprint</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb22c9fdba12" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/how-i-learn-quantum-computing-bb22c9fdba12">How I Learn Quantum Computing</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Book review: Deep Learning with Python, 2017, François Chollet, Manning]]></title>
            <link>https://medium.com/data-science/book-review-deep-learning-with-python-2017-fran%C3%A7ois-chollet-manning-99c36faa5a29?source=rss-9cf1f3f55c40------2</link>
            <guid isPermaLink="false">https://medium.com/p/99c36faa5a29</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[book-review]]></category>
            <dc:creator><![CDATA[Christophe Pere]]></dc:creator>
            <pubDate>Thu, 15 Oct 2020 04:45:36 GMT</pubDate>
            <atom:updated>2020-10-15T22:22:36.089Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SA3A1kIC9e0_NqwbHIy2Kg.jpeg" /><figcaption>Take by the author — Deep Learning with Python, 2017, François Chollet book and my cat</figcaption></figure><h4>A great tour in the world of Deep Learning in less than 10 minutes.</h4><p>It took me a long time to open this book. More for fear of finding that I knew nothing more than for fear of being frustrated with knowing everything. I regularly receive newsletters on &quot;best of&quot; or &quot;most read&quot; books about artificial intelligence, machine learning, or deep learning. <em>Deep Learning with Python </em>is consistently cited as one of the most recommended. The given level changes quite often between advanced, intermediate, or expert. I think that we should not stop at a level estimated by someone. You have to pick up and read a book out of interest, out of need.</p><p>This book is accessible to anyone wishing to learn. The fluidity and simplicity of writing allow an understanding of all the concepts regardless of the level.</p><h3>Part 1: Fundamentals of deep learning</h3><h4>Chapter 1 — What is deep learning?</h4><p>Chapter 1 of the book gives to the reader a good <strong>overview of the definitions </strong>employed in the domain and what exactly we call <strong><em>learning</em></strong> in the manner of an algorithm. The author tells <strong>the history </strong>of artificial intelligence with simplicity and concision.</p><p>There is a lot of <strong>explanations with the context </strong>to explain what is deep learning and why it just appears recently in our industries and in our real-world (hardware, data, Moore’s law…).</p><p>The author provides the reader with a clear explanation of different machine learning algorithms and how neural networks work.</p><p>I’d appreciated the context of the use of the algorithms and the parallel with the use in competitions (why this type for a specific task).</p><h4>Chapter 2 — [..] Mathematical building blocks of neural networks</h4><p>So here we are, in the <strong><em>math</em></strong> part of the book. Well, every people just scared by these few words but, the author has a <strong><em>particular method </em></strong>to explain the math behind a neural network. His own words are:</p><blockquote>Although this section deals entirely with linear algebra expressions, you won’t find any mathematical notation here. I’ve found that methematical concepts can be more readily mastered by programmers with no mathematical background if they’re expressed as short Python snippets instead of mathematical equations. So we’ll use Numpy code throughout.</blockquote><p>It’s right, no mathematical formulas. So, don’t be afraid of the math or become crazy thinking that it will be hard or impossible. The author cut the different parts of the math behind the learning process <strong><em>very simple and explain them with Numpy code</em></strong>.</p><p>With this chapter, you’ll be familiar with <strong><em>vector, matrix, and tensor (and their corresponding real-world application)</em></strong>. The different <strong><em>operations used with tensors </em></strong>and the corresponding <strong><em>representation for the neural networks</em></strong>. You’ll also learn about <strong><em>differentiable function </em></strong>and <strong><em>gradient </em></strong>and what is <strong><em>gradient descent, stochastic gradient descent, </em></strong>and the different <strong><em>corresponding parameters for the neural networks</em></strong>.</p><p>Clear and concise this chapter is very well explained and <strong><em>permits us to have a good understanding </em></strong>of tensor manipulation and representation learning.</p><p>The author use geometry to permit the reader to <strong><em>visualize the concepts </em></strong>he explains.</p><p>Bonus, in just a few lines you’ll be familiar with <strong><em>backpropagation</em></strong> and the math behind it. The author reuses an example of the previous chapter and cuts it in parts to map the relevant mathematical concepts you just learn.</p><p>I was a little hesitant at the beginning but, I eagerly went through these <strong><em>thirty pages</em></strong>.</p><h4>Chapter 3 — Getting Started with neural networks</h4><p>With this chapter, the reader is capable of handle most commons problems with neural networks as classification (binary and multiclass) and regression.</p><p>The author explains the different parts of neural networks (layers, input data, loss function, optimizer). He provides code blocks coded in Keras with an explanation of how they work.</p><p>You’ll find very relevant information about loss function and optimizer.</p><p>So, the examples. Three are provided in this chapter, one for each common problem (binary classification, multiclass classification, regression). The author provides the best practices and what to look at with visualization. He put the light on overfitting and how to evaluate your model and, what loss function to use for the different problems.</p><p>You’ll have a good understanding of the output of the neural networks for the three cases. One highlight shows are on the size of the network, it’s important to scale your network taking into account the size of your dataset. If the dataset is small choose small neural networks with few layers to avoid overfitting.</p><p>These 36 pages are very useful and full of information and best practices.</p><h4>Chapter 4 — Fundamentals of machine learning</h4><p>This chapter will prepare the reader with a survey on the different branches of the machine learning world. You’ll be exposed to a quick description of the four concepts in the ML world.</p><p>The author will present the different concepts between classification and regression and the different metrics and loss functions.</p><p>You’ll know how to evaluate your model and all the steps needed to prepare a project. Beginning with the data to finish with hyperparameter tuning.</p><p>The author presents the importance of train, evaluate, and test. You’ll know the common ways to evaluate your model and the code behind the different methods. You’ll also find proper information about feature engineering and the format of the data.</p><p>You’ll find proper information about overfitting and underfitting and what that’s mean for your model also the ways to avoid them. The author provides a great explanation about <em>dropout</em> and how to use it.</p><p>And the last thing, the machine learning workflow that every project needs to take. You’ll find the different hypothesis and the step by step to follow when starting a machine learning problem.</p><p>So it’s a small chapter (26 pages) but with a lot of important information to keep in mind during a project of research in machine learning.</p><p><strong><em>Resume part 1</em></strong></p><p>At this point, you reached the end of the first part of the book, you passed through all the fundamental parts of the deep learning world and how to use them precisely in your project. You’ll know where to start, what to look for, how to prepare your data, how to train, evaluate, and test your model. The importance of the understanding of the math behind every part of the algorithm. But most importantly, you have the context of this discipline and the definition of the processes.</p><h3>Part 2: Deep Learning in Practice</h3><h4><em>Chapter 5 — Deep Learning for Computer Vision</em></h4><p>In this chapter, the author will explain all the concepts of Convolutional Neural Networks (CNN). There is a lot of information in this section.</p><p>The author began with the operations of how CNN works (filters, padding, strides, pooling…). Then you’ll know how to use them in a small dataset to obtain great results. You will be familiar with the overfitting concept in computer vision and how to avoid it (data augmentation, dropout…).</p><p>The next step is illustrated by pre-trained models, their goal, how they are obtained, and how to use them in different cases to increase the accuracy of your predictions. The author explains the concept of feature extraction and the concept of fine-tuning (tune the last layers of a pre-trained CNN to learn specific filters or representations of your specific data) and how to use them in the case of low datasets.</p><p>The chapter ended with the visualization of how convnets see the world. Three methods to look into the different abstract representation of each layer of your model.</p><p>The author uses an example of image classification (dog/cat), which provides a lot of codes explaining each step of all the things he describes.</p><h4>Chapter 6 — Deep Learning for text and sequences</h4><p>After exploring the world of image recognition the author leads us inside the world of text and sequence data. This part is really amazing for those interested in NLP and Time Series problem.</p><p>The chapter begins with explanations of how the data need to be prepare. You’ll have knowledge about tokenization, n-grams, one-hot encoding, and word embeddings (the best explanation of it I see was in the <a href="https://www.coursera.org/lecture/nlp-sequence-models/learning-word-embeddings-APM5s">Deep Learning Specialization provided by Coursera</a>). The author provides lots of code to use these different techniques and pretrained models (<em>Glove</em>, …).</p><p>After the part about data. You’ll explore the world of Recurrent Neural Networks (RNN) and their variations, LTMS, GRU, and Bidirectional. The author provides enough theory to understand the code (Keras) with concrete examples. You’ll be able to use the different models on your text data and reproduce easily the results showing in this first part of the chapter.</p><p>The end of the chapter is about more advanced applications of RNNs as Time Series and Text generation. You’ll also learn how to use dropout in RNN and how to use CNN for text or time series but you’ll see the disadvantages of this type of model when considering time series.</p><h4>Chapter 7 — Advanced deep learning best practices</h4><p>At this step of the book, you will reach the advanced features of Keras. The author provides you advice to pass from the Sequential model to the functional API. Why this important? Because you can with this usability to have multi-input models or multi-output models.</p><p>You’ll have an explanation of acyclic graphs (as the Inception model), Residual connections (ResNet models), sharing weights between layers, or using models as layers.</p><p>You also have best practices about monitoring your model with Tensorboard and callbacks (the different types and how to use them). And you’ll learn how to and when to use batch normalization and depthwise separable convolution.</p><p>The most important part of this chapter, for me, is the part of hyperparameter optimization. The author presents different ways to tune them and how to use ensemble models.</p><p>You’ll have condensed pieces of information in 36 pages but it’s very helpful.</p><h4>Chapter 8 — Generative deep learning</h4><p>Exciting chapter, then this one. The first part is for text generation, you’ll learn how to code a language model to generate text with different possibilities. The most important thing will know how to reweight the probability distribution for the next character or the next word in order to generate creativity in the text generation.</p><p>Then, you’ll have access to a lot of information on DeepDream and how to use it with pre-trained models. You’ll learn how to create new pictures and what is the mechanism inside this generation.</p><p>Neural style transfer, What is it? You’ll learn it in this chapter, it’s the ability to take the content of one picture and the style of one other and to mix them in a new picture. Yes, you’ll learn that <em>content </em>and <em>style </em>can be mathematically written and put inside a neural net to mix them.</p><p>Variational Auto-Encoder and Generative Adversarial Networks here we are. In a few pages ~20 you have a lot of information about VAEs and GANs for image generation. You’ll find relevant information to distinguish both and to select which to use in your case. GANs are the most difficult to train so the author provides different tricks to allow you to have a better understanding of the behavior of the model. The GAN part is for me the most interesting because I never use them.</p><p>I finish this chapter with good intuition about the different techniques for generative data. Image generation is the biggest part but also the most interesting with GANs.</p><h4>Chapter 9 — Conclusions</h4><p>The author provides a concise summary of the book at the beginning of this chapter. Then, the author gave a good understanding of the limitations of deep learning and place it in the world of AI. You also find the feelings of the author about the future of deep learning and where to look in your exploration. One point, about AutoML, was interesting to put in parallel with the recent advancements in this field. You also find information on how to stay up to date with the field.</p><h4>Final words</h4><p>I hope this short summary of the book will give you relevant information about the content and allows you to find what you need. I have had this book for a long time in my library, purchased for the purpose of primarily using Chapter 6 which deals with NLP.</p><p>I am currently in a different quest, to fill all the weaknesses of my self-learning. So, I launched into challenges to go beyond my comfort zone. The first step put the ego aside and admit that I do not know everything (far from it). The rest, to conquer the textbooks that can help. Deep Learning with Python is a foundational stone long-listed as a benchmark. After exploring it and taking countless notes and post-its I feel ready to continue my journey into subdomains that interest me.</p><h4><strong>About the author:</strong></h4><p>François Chollet is an AI researcher on the Google Brain Team and author of the Keras deep-learning library.</p><p><strong>François Chollet, <em>Deep learning with Python </em>(2017), Manning</strong></p><blockquote>Waiting for the publication of the second edition</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99c36faa5a29" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/book-review-deep-learning-with-python-2017-fran%C3%A7ois-chollet-manning-99c36faa5a29">Book review: Deep Learning with Python, 2017, François Chollet, Manning</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Image Classification? Data Augmentation? Transfer Learning?]]></title>
            <link>https://medium.com/data-science/what-is-image-classification-data-augmentation-transfer-learning-689389c3f6c8?source=rss-9cf1f3f55c40------2</link>
            <guid isPermaLink="false">https://medium.com/p/689389c3f6c8</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[image-classification]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <dc:creator><![CDATA[Christophe Pere]]></dc:creator>
            <pubDate>Sat, 03 Oct 2020 02:52:12 GMT</pubDate>
            <atom:updated>2020-10-03T18:16:35.653Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*udTGYZXI66T97r3w8C3lGA.png" /><figcaption>Source: Images taken by the author and annotated by him</figcaption></figure><h4>The difference between the techniques and their applications</h4><blockquote>This article is the first part of three articles about computer vision. Part 2 will explain Object Recognition. Part 3 will be about Image Segmentation.</blockquote><blockquote>With this article is provided a notebook: <a href="https://github.com/Christophe-pere/Image_classification">here </a>on GitHub</blockquote><h4>Introduction</h4><p>What is more exciting than seeing the world? To be able to see the best around us? The beauty of a sunset, the memorable waterfalls, or the seas of ice? Nothing would be possible if evolution hadn’t endowed us with eyes.</p><p>We recognize things because we have learned the shape of objects, we have learned to estimate that different shape from those we have encountered can be associated with the same object. We have learned by experience and because we were given the names of said objects. Like a supervised algorithm that needs a label to associate the shape, details, colors with a category. A dog and a wolf are very similar just across the pixels. Computer vision methods have enabled machines to be able to decipher these shapes and “learn” to classify them.</p><p>Now, algorithms, just like our eyes can identify in pictures or films, objects, or shapes. The methods are constantly evolving and perfecting to the point of reaching the so-called human level. But, there are several methods, image classification, object detection or recognition, and image segmentation. In this article, we will explore the image classification problem. The first part will present training a model from scratch, the second will present training with data augmentation, and the last transfer learning with pre-trained models.</p><h4>Methods</h4><p><strong><em>Image Classification from scratch</em></strong></p><p>Image classification can, when the volume of data you have is large enough, be done “<em>from scratch</em>”. The idea is to create a model and train it from scratch.</p><p>Like any classification problem, the data must be annotated. How to proceed when it comes to images? It’s quite simple in fact, the data of the same class must be stored in the same folder. It is necessary to take a folder per class or category considered. Like that:</p><pre>&gt; train/<br>      ... forest/<br>            ... img_1.jpeg<br>            ... img_2.jpeg<br>            ...<br>      ... moutain/<br>            ... img_1.jpeg<br>            ... img_2.jpeg<br>            ...<br>      ... sea/<br>            ... img_1.jpeg<br>            ... img_2.jpeg<br>      ...<br>  validation/<br>      ... forest/<br>            ... img_1.jpeg<br>            ... img_2.jpeg<br>            ...<br>      ... moutain/<br>            ... img_1.jpeg<br>            ... img_2.jpeg<br>            ...<br>      ... sea/<br>            ... img_1.jpeg<br>            ... img_2.jpeg<br>  test/<br>      ... forest/<br>            ... img_1.jpeg<br>            ... img_2.jpeg<br>            ...<br>      ... moutain/<br>            ... img_1.jpeg<br>            ... img_2.jpeg<br>            ...<br>      ... sea/<br>            ... img_1.jpeg<br>            ... img_2.jpeg</pre><p>This simple way allows the model to associate a label with a picture.</p><p>After that, you build your neural network. From now, the standard is for Convolutional Neural Networks (<em>CNN</em>) when working with pictures. So you are going to build a CNN and train it with the INTEL data set. You’ll add a convolutional layer then a pooling layer, maybe a dropout layer to decrease the risk of overfitting and finishing with dense fully connected layers. The last one will output the results, or the prediction, The number of unit in this last layer is the number of classes you want to predict.</p><pre><strong><em># building the model</em></strong><br>model = tf.keras.Sequential([<br>  layers.Conv2D(32, 3, activation=&#39;relu&#39;),<br>  layers.MaxPooling2D(),<br>  layers.Dropout(0.5),<br>  layers.Conv2D(32, 3, activation=&#39;relu&#39;),<br>  layers.MaxPooling2D(),<br>  layers.Dropout(0.3),<br>  layers.Conv2D(32, 3, activation=&#39;relu&#39;),<br>  layers.MaxPooling2D(),<br>  layers.Flatten(),<br>  layers.Dense(128, activation=&#39;relu&#39;),<br>  layers.Dense(num_classes, activation=&#39;softmax&#39;)<br>])</pre><pre><strong><em># compile the model with adam optimizer and sparse cross entropy</em></strong> model.compile(<br>  optimizer=&#39;adam&#39;,<br>  loss=tf.losses.SparseCategoricalCrossentropy(from_logits=True),<br>  metrics=[&#39;accuracy&#39;])</pre><pre><strong><em># use early stopping to break the learning process if the model stop learning during 3 epochs<br></em></strong>es = tf.keras.callbacks.EarlyStopping(patience=3)<br>history = model.fit(<br>  train_x,train_y,<br>  validation_data=(valid_x, valid_y), callbacks=[es], batch_size=32,<br>   epochs=30<br>)</pre><p>Here, I present a small CNN architecture where num_classes is the number of classes. In the context of this article we will predict 6 classes, so num_classes=6. EarlyStopping constrains the model to stop when it overfits, the parameter patience=3 means that if during 3 epochs the model doesn’t improve, the training process is stopped.</p><p>If you have enough data and if your CNN is not too deep - but enough - to generate a good data representation you’ll obtain good results.</p><p>Unfortunately, is rarely the case and you need to try other options.</p><p><strong><em>Data augmentation</em></strong></p><p>So, if your model can’t obtain a good performance. You can change the architecture of your network. You can add or delete hidden layers. You can decrease or increase the number of units per layer. You can change the activation function or loss function. Or, you can change the preprocessing or your data.</p><p>But, what to do if it’s not enough?</p><p>You can use <em>data augmentation</em>. This technique permits you to create artificially (synthetic) images from yours in-memory (your original data will not be affected by this method). It consists of operations like rotation, the same picture will be rotated by different angles (creation of new images). Shifted, that is to say, that the pattern of the image will be offset from the frame, thus creating a “hole” which will have to be interpolated. This operation can be done horizontally or vertically. Zooming, the new image will be a zoom of a part in the original data, etc…</p><p>The perfect tool to do this is the object named ImageDataGenerator provided by Keras[2] (keras.preprocessing.image.ImageDataGenerator()).</p><pre>from tensorflow.keras.preprocessing.image import ImageDataGenerator<br>data_gen = ImageDataGenerator(<br>        rotation_range=40,<br>        width_shift_range=0.2,<br>        height_shift_range=0.2,<br>        rescale=1./255,<br>        shear_range=0.2,<br>        zoom_range=0.2,<br>        horizontal_flip=True,<br>        fill_mode=&#39;nearest&#39;)<br>test_gen = ImageDataGenerator(rescale=1./255)</pre><p>Here are just example values I used in the notebook.</p><p>This tool will create synthetic images to increase the volume of your dataset. How to use it?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed6e81a9aed5cb0ea71c0c9c05c017e2/href">https://medium.com/media/ed6e81a9aed5cb0ea71c0c9c05c017e2/href</a></iframe><p>Quick implementation of data augmentation used in a CNN. The results will be displayed in the Results section.</p><p>Unfortunately, yes again, you can have too few images to obtain good results. If your dataset is very small, even data augmentation can not save you. What do you do next?</p><p><strong><em>Transfer Learning[3]</em></strong></p><p>No, this is not the time to run away afraid of transfer learning. What is transfer learning? It is simply a method where you’ll use the knowledge learned for one task and exporting it to another.</p><p>In our case, transfer learning takes place with fairly large models (with millions or even hundreds of millions of parameters) that have been trained on a gigantic volume of data (the Imagenet[4] dataset) to generalize.</p><p>When you have a small dataset, the models you build cannot have a good representation of the data. You must therefore use pre-trained models that you will train on your data.</p><p>The method is simple, take the pre-trained model(s), freeze the weights of their layers, leave only the last layer, or the last layers to then train them with your data.</p><p>Neural networks specialize more and more according to their depth. The first layers will detect general patterns, lines for example. Then shapes will appear until you reach very fine details in the last layers. These are the ones that must be used to “tune” the model to your data. So rather than retraining the complete model with the ImageNet dataset plus your data (which would take months and require a significant investment of money) you can in minutes/hours obtain an extremely performing model using transfer learning.</p><p>In the notebook, I compare different pre-trained models to see which is the best for our study. To change the pre-trained model easily and quickly, the function below contains the architecture for tuning a pre-trained model on the data and evaluate it with metrics. The return is a data frame containing the results of the metrics, and the history of the model to plot the learning curves.</p><p>The next <em>gist </em>will show you how to use the function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0834089fb86662da6c24be99ef0307f2/href">https://medium.com/media/0834089fb86662da6c24be99ef0307f2/href</a></iframe><p>Yes, you need metrics to evaluate the performance of your different algorithms and you need to plot the learning curves (accuracy and loss) to look at the behavior of your training.</p><p><strong><em>Metrics</em></strong></p><p>To evaluate classification models different metrics can be used such as accuracy, precision, recall, f1-score, etc. (details of these metrics can be found <a href="https://towardsdatascience.com/model-selection-in-text-classification-ac13eedf6146">here</a>). The code below shows how to set up a metrics dictionary and the function that will be used to evaluate neural networks.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eab71c4decc61d913ceec39da47a705f/href">https://medium.com/media/eab71c4decc61d913ceec39da47a705f/href</a></iframe><p>This function can be used in binary and multiclass classification problem.</p><p><strong><em>Plotting learning curves</em></strong></p><p>It’s very important when training a deep learning model to see the behavior of the learning curves to determine if the model as bias, overfit, or normal behavior. To do it, let’s see the code below which permits to plot the accuracy and loss curves for the training set and the evaluation set.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/da970f743d34ccb6d2ced0878ffda093/href">https://medium.com/media/da970f743d34ccb6d2ced0878ffda093/href</a></iframe><p>At this point, you know the different methods and the metrics used to evaluate the models.</p><h4>Data</h4><p>To avoid the classic MNIST[5] or FashionMNIST[6] for classification, we will take the dataset provided by INTEL (available on Kaggle[1]). These data are more fancies, they represent scenes from all over the world and represented 6 classes (buildings, forest, mountain, glacier, sea, and street). The data volume is also accessible for a project on a local computer because the training set is made up of 14k images, the validation set contains 3k images and 7k for the test. Each image has a shape of (150x150) pixels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*16k8ElKN8WEKJqIZT3RoxQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*ZonjS637cl-OlRefGGRCFQ.jpeg" /><figcaption>Building images from the train set</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*kOcZkvXI4H2ZXxZrb_aWWQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*lP46Dc99xU742X_JDnbEfw.jpeg" /><figcaption>Forest images from the train set</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*hx0izWd_lY2NYMf7qnTsEQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*dEP5JdqRP6NgVqzTIUJyIg.jpeg" /><figcaption>Glacier images from the train set</figcaption></figure><p>Better than clothes isn’t it?</p><p>How to load and prepare the data? First, you need to configure the different paths to reach the data.</p><pre><strong><em># creating paths to retrieve the data</em></strong><br>ROOT = &quot;/mnt/d&quot;<br>FOLDER = &quot;INTEL_images_classification&quot;<br>TRAIN = os.path.join(ROOT, FOLDER, &#39;seg_train/seg_train&#39;)<br>TEST = os.path.join(ROOT, FOLDER, &#39;seg_test/seg_test&#39;)<br>PRED  = os.path.join(ROOT, FOLDER, &#39;seg_pred/seg_pred&#39;)</pre><p>You then need to pass from pictures (.jpg) to NumPy array of values.</p><pre>def prepare_dataset(path,label):<br>    x_train=[]<br>    y_train=[]<br>    all_images_path=glob(path+&#39;/*.jpg&#39;)<br>    for img_path in tqdm(all_images_path) :<br>       img=load_img(img_path, target_size=(150,150))<br>       img=img_to_array(img)<br>       img=img/255.0   <strong><em># here you normalize the data between 0 and 1</em></strong><br>       x_train.append(img)<br>       y_train.append(label)<br>    return x_train,y_train</pre><p>This function will generate a matrix with all the images and the associated labels. You can see that the pixel values will be rescaled between [0, 1]. Deep learning models performed better with this range of values because the range 255 is made for ‘<em>RGB</em>’ color, an algorithm doesn’t understand ‘color’. Well, time to extract the data:</p><pre><strong><em># Train dataset</em></strong><br>labels = os.listdir(TRAIN)<br>x = []<br>y = []<br>for label in labels:<br>    x_, y_ = prepare_dataset(os.path.join(TRAIN, label), label)<br>    x.extend(x_)<br>    y.extend(y_)<br>x = np.array(x)<br>y = np.array(y)</pre><pre><strong><em># Test dataset</em></strong><em> </em><br>labels = os.listdir(TEST)<br>x_test = []<br>y_test = []<br>for label in labels:<br>    x_, y_ = prepare_dataset(os.path.join(TEST, label), label)<br>    x_test.extend(x_)<br>    y_test.extend(y_)<br>x_test = np.array(x_test)<br>y_test = np.array(y_test)</pre><p>Here you have a training set and a test set. You need next to split the training set into <em>train </em>and <em>validation </em>sets (80/20 is enough with this volume). Scikit-learn is here for us with the train_test_split function:</p><pre># create a validation set <br>from sklearn.model_selection import train_test_split<br>train_x, valid_x, y_train, y_valid = train_test_split(x, y, random_state=42, stratify=y, test_size=0.2)</pre><p>Almost perfect, one more thing, the labels are still in <em>string</em> type. Models don’t appreciate this kind of data, so you need to encode them (int values needed):</p><pre>from sklearn import preprocessing</pre><pre><strong><em># create the label encoder</em></strong><br>encoder = preprocessing.LabelEncoder()<br><strong><em># train it on the training labels set</em></strong> <br>train_y = encoder.fit_transform(y_train)<br><strong><em># apply it on the other corresponding labels</em></strong> <br>valid_y = encoder.transform(y_valid)<br>test_y  = encoder.transform(y_test)</pre><p>Now, it’s perfect. You have the methods, the metrics, and the data.</p><h4>Results</h4><p><strong><em>From scratch</em></strong></p><p>The simple CNN model presented in the section <strong><em>Methods </em></strong>has been trained on the dataset. After 10 epochs the training is stopped because the algorithm is no longer learning.</p><pre>Epoch 1/30<br>351/351 [==============================] - 536s 2s/step - loss: 1.1578 - accuracy: 0.5443 - val_loss: 1.0311 - val_accuracy: 0.6138<br>...<br>Epoch 10/30<br>351/351 [==============================] - 649s 2s/step - loss: 0.2364 - accuracy: 0.9146 - val_loss: 0.6711 - val_accuracy: 0.7887</pre><p>The corresponding curves show us that the accuracy ~75% on the test set is reached after 3 epochs. The model continues to learn on the train but can’t generalize as shown by the validation accuracy. The losses show the same thing, after 3 epochs the loss on the validation set doesn’t change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/1*8gDTONRBFJPgsDlZHbQp2g.png" /><figcaption>Accuracy and losses curves for the “from scratch” model</figcaption></figure><p>Corresponding metrics:</p><pre>  accuracy          : 78.33%<br>  balanced_accuracy&#39;: 78.44%<br>  precision         : 78.94%<br>  recall            : 78.33%<br>  f1-score          : 78.31%<br>  cohens_kappa      : 73.97%<br>  matthews_corrcoef : 74.10%<br>  roc_auc           : 93.37%</pre><p>The results on the test set are not so bad, reaching ~78+% on the accuracy, precision, and recall. It’s a good start for the classification.</p><p><strong><em>Data augmentation</em></strong></p><pre>Epoch 1/50<br>62/62 [==============================] - 1116s 18s/step - loss: 2.0628 - accuracy: 0.1857 - val_loss: 1.7963 - val_accuracy: 0.1925</pre><pre>...<br>Epoch 11/50<br>62/62 [==============================] - 984s 16s/step - loss: 0.9419 - accuracy: 0.6369 - val_loss: 0.9811 - val_accuracy: 0.5925</pre><p>The training ends with poor results. The learning curves show that the training wasn’t good enough. This can be changed by tuning the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*hUcwKxFnSzv_oWPVa8RFqw.png" /><figcaption>Learning curves data augmentation</figcaption></figure><p>As you see, even if the results aren’t perfect, the learning is better. The curves between the train et and the validation are closer. So the training is more stable.</p><p>The associated metrics are shown below:</p><pre>accuracy          | 68.60%<br>balanced_accuracy | 68.13%<br>precision         | 70.28%<br>recall            | 68.61%<br>f1-score          | 67.54%<br>cohens_kappa      | 62.18%<br>matthews_corrcoef | 62.76%<br>roc_auc           | 93.73%</pre><p><strong><em>Transfer Learning</em></strong></p><p>The models tested in this study are below:</p><pre>Xception[7]           | ResNet50V2[12]  | InceptionV3[14]<br>VGG16[8]              | ResNet101V2     | <br>VGG19                 | ResNet152V2     | <br>InceptionResNetV2[9]  | DenseNet121[13] | <br>MobileNetV2[10]       | DenseNet169     |<br>NASNetLarge[11]       | DenseNet201     |</pre><p>Yes, a lot of pre-trained models are implemented in Keras (here are just part of them). Each of them had been trained on the ImageNet dataset. The table below presents the results for each model trained on our data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9cf1ef7b41d72ce07f6104a115169e26/href">https://medium.com/media/9cf1ef7b41d72ce07f6104a115169e26/href</a></iframe><blockquote>The NASNetLarge model hasn’t been tested because of the input_shape. The model takes into account pictures with shape (331, 331, 3).</blockquote><p>These results were obtained with EarlyStopping(patience=1) that means if the model doesn’t learn from epoch to another the learning process just stops. Why one? Because of the time consuming to test all the models. These results were also obtained by tuning only the top layer of each model. In order to increase performances, it is possible to tune more layers.</p><h4>Discussion</h4><p>The data augmentation method is the most delicate, the results are not those expected. The complexity of the model needs to be tuned in order to increase performance. The implementation of from scratch and transfer learning methods are by far the easiest to set up.</p><h4>Conclusion</h4><p>The pre-trained models with the transfer learning method allow us to obtain the best results on the data set. The performances could be increased with fewer constraints on the early stopping parameter and tuning more layers of the pre-trained models. Obviously, it will be more time consuming. <br>The “<em>from scratch</em>” and data augmentation methods have shown interesting results but do not surpass transfer learning.<br>The ResNet101V2 model achieved an accuracy of 90.33% and a precision of 90.36% on the INTEL dataset (test set). It is the winner of the comparison.</p><p>I hope you found this article interesting and it will help you in your future image classification projects. Computer vision’s next article will be on object detection in images. See you soon.</p><h4>References</h4><p>[1] <a href="https://www.kaggle.com/puneet6060/intel-image-classification">https://www.kaggle.com/puneet6060/intel-image-classification</a> <br>[2] keras.io <br>[3] Pratt, L. Y. (1993). <a href="http://papers.nips.cc/paper/641-discriminability-based-transfer-between-neural-networks.pdf">“Discriminability-based transfer between neural networks”</a> (PDF). <em>NIPS Conference: Advances in Neural Information Processing Systems 5</em>. Morgan Kaufmann Publishers. pp. 204–211.<br>[4] Olga Russakovsky et al. “ImageNet Large Scale Visual Recognition Challenge”. IJCV, 2015.<br>[5] <a href="http://yann.lecun.com/exdb/publis/index.html#lecun-98">LeCun, Y. et al., 1998. “Gradient-based learning applied to document recognition.” Proceedings of the IEEE, 86(11):2278–2324</a><br>[6] Han X., Kashif R., and Roland V., 2017. Fashion-MNIST: a Novel Image Dataset for Benchmarking Machine Learning Algorithms <a href="https://arxiv.org/abs/1708.07747">arXiv preprint</a><br>[7] Chollet F., 2016. Xception: Deep Learning with Depthwise Separable Convolutions <a href="https://arxiv.org/abs/1610.02357">arXiv preprint</a> <br>[8] Simonyan K. and Zisserman A., 2014. Very Deep Convolutional Networks for Large-Scale Image Recognition <a href="https://arxiv.org/abs/1409.1556">arXiv preprint</a><br>[9] Szegedy C. et al., 2016. Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning <a href="https://arxiv.org/abs/1602.07261">arXiv preprint</a><br>[10] Sandler M. et al., 2019. MobileNetV2: Inverted Residuals and Linear Bottlenecks <a href="https://arxiv.org/pdf/1801.04381.pdf">arXiv preprint</a><br>[11] Zoph B. et al., 2018. Learning Transferable Architectures for Scalable Image Recognition <a href="https://arxiv.org/pdf/1707.07012.pdf">arXiv preprint </a><br>[12] He K. et al., 2016. Deep Residual Learning for Image Recognition <a href="https://arxiv.org/abs/1512.03385">arXiv preprint</a><br>[13] Huang G. et al., 2017. Densely Connected Convolutional Networks <a href="https://arxiv.org/abs/1608.06993">arXiv preprint</a><br>[14] Szegedy C. et al., 2016. Rethinking the Inception Architecture for Computer Vision <a href="https://arxiv.org/abs/1512.00567">arXiv preprint</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=689389c3f6c8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/what-is-image-classification-data-augmentation-transfer-learning-689389c3f6c8">What is Image Classification? Data Augmentation? Transfer Learning?</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use Deep Learning for Time Series Forecasting]]></title>
            <link>https://medium.com/data-science/how-to-use-deep-learning-for-time-series-forecasting-3f8a399cf205?source=rss-9cf1f3f55c40------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f8a399cf205</guid>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[time-series-forecasting]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Christophe Pere]]></dc:creator>
            <pubDate>Mon, 21 Sep 2020 20:13:18 GMT</pubDate>
            <atom:updated>2020-09-21T20:58:08.604Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GNToQNhlfb7i43kBoMHnUQ.png" /><figcaption>Source: Result of the study — computed by the author</figcaption></figure><h4>An application of the RNN family</h4><h4>Introduction</h4><p>For a long time, I heard that the problem of time series could only be approached by statistical methods (AR[1], AM[2], ARMA[3], ARIMA[4]). These techniques are generally used by mathematicians who try to improve them continuously to constrain stationary and non-stationary time series.</p><p>A friend of mine (mathematician, professor of statistics, and specialist in non-stationary time series) offered me several months ago to work on the validation and improvement of techniques to reconstruct the lightcurve of stars. Indeed, the <em>Kepler </em>satellite[11], like many other satellites, could not continuously measure the intensity of the luminous flux of nearby stars. The Kepler satellite was dedicated between 2009 and 2016 to search for planets outside our Solar System called extrasolar planets or exoplanets.</p><p>As you have understood, we are going to travel a little further than our planet Earth and deep dive into a galactic journey whose machine learning will be our vessel. As you can understand, astrophysics has remained a strong passion for me.</p><blockquote>The notebook is available on Github: <a href="https://github.com/Christophe-pere/Time_series_RNN">Here</a>.</blockquote><h4>RNN, LSTM, GRU, Bidirectional, CNN-x</h4><p>So what ship will we carry through this study? We will use the recurrent neural networks (RNN[5]), models. We will use LSTM[6], GRU[7], Stacked LSTM, Stacked GRU, Bidirectional[8] LSTM, Bidirectional GRU, and also CNN-LSTM[9]. For those passionate about tree family, you can find a great article on XGBoost and time series written by Jason Brownlee <a href="https://machinelearningmastery.com/xgboost-for-time-series-forecasting/">here</a>. A great repository about time series is available on <a href="https://github.com/Jenniferz28/Time-Series-ARIMA-XGBOOST-RNN">github</a>.</p><p>For those who are not familiar with the RNN family, see them as learning methods with memory effect and the ability to forget. The bidirectional term comes from the architecture, it is about two RNN which will &quot;read&quot; the data in one direction (from left to right) and the other (from right to left) in order to be able to have the best representation of long-term dependencies.</p><h4>Data</h4><p>As said earlier in the introduction, the data correspond to flux measurements of several stars. Indeed, at each temporal increment (hour), the satellite made a measurement of the flux coming from nearby stars. This flux, or magnitude, which is light intensity, varies over time. There are several reasons for this, the proper movement of the satellite, rotation, angle of sight, etc. will vary. Therefore the number of photons measured will change, the star is a ball of molten material (hydrogen and helium fusion) which has its own movement therefore the emission of photons is made depending on its movement. This corresponds to fluctuations in light intensity.</p><p>But, there can also be planets, exoplanets, which disturb the star or even pass between the star and in the line of sight of the satellite (transit method[12]). This passage obscures the star, the satellite receives fewer photons because they are blocked by the planet passing in front of it (a concrete example is a Solar eclipse due to the Moon).</p><p>The set of flux measurements is called a light curve. What does a light curve look like? Here are some examples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vmqB6hBITI_uNf0SqPg4pA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qvOp7kwkHLCn-uSAOkmghA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TSydz-0y6xNoi9KUMUqPwA.jpeg" /></figure><p>The fluxes are very different from one star to another. Some are very noisy while others have great stability. The fluxes nevertheless present anomalies. Holes, or lack of measurement, are visible in the light curves. The goal is to see if it is possible to predict the behavior of light curves where there is no measurement.</p><h4>Data Reduction</h4><p>In order to be able to use the data in the models, it is necessary to carry out a data reduction. Two will be presented here, the <em>moving average</em> and <em>window method</em>.</p><p><strong><em>Moving average:</em></strong></p><p>The moving average consists of taking X successive points and compute the mean on them. This method permits to reduce the variability and delete the noise. This also reduces the number of points, it’s a downsampling method.</p><p>The following function allows us to compute a moving average from a list of points by giving a number that will be used to compute the average and the standard deviation of the points.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b971610ef620419ad6579c276b4ba8d/href">https://medium.com/media/2b971610ef620419ad6579c276b4ba8d/href</a></iframe><p>You can see that the function takes 3 parameters in the input. <strong><em>time </em></strong>and <strong><em>flux </em></strong>are the <strong><em>x</em></strong> and <strong><em>y</em></strong> of the time series. <strong><em>lag </em></strong>is the parameter controlling the number of points takes into account to compute the mean of the time and flux and the standard deviation of the flux.</p><p>Now, we can take a look at how to use this function and the result obtained by the transformation.</p><pre><strong><em># import the packages needed for the study</em></strong><br>matplotlib inline<br>import scipy<br>import pandas as pd<br>import numpy as np<br>import matplotlib.pyplot as plt<br>import sklearn<br>import tensorflow as tf<br><strong><em># let&#39;s see the progress bar</em></strong><br>from tqdm import tqdm<br>tqdm().pandas()</pre><p>Now we need to import the data. The file kep_lightcurves.csv contains the data from the 13 stars. Each star has 4 columns, the original flux (‘…_orig’), the rescaled flux is the original flux minus the average flux (‘…_rscl’), the difference (‘…_diff’), and the residuals (‘…_res’). So, 52 columns in total.</p><pre># reduce the number of points with the mean on 20 points<br>x, y, y_err  = moving_mean(df.index,df[&quot;001724719_rscl&quot;], 20)</pre><p>df.index correspond to the time of the time series<br>df[“001724719_rscl”] rescaled flux of the star (“001724719”)<br>lag=20 is the number of points where the mean and the std will be computed</p><p>The result for the 3 previous lightcurves:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n2WUUUb5bLxmTUbpY98TgA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GNToQNhlfb7i43kBoMHnUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DuKp8zgTxZOfPhQNVZMtKg.png" /><figcaption>Lightcurves of the 3 previous stars with a moving average showing the points between 25,000 and 30,000 measures</figcaption></figure><p><strong><em>Window Method:</em></strong></p><p>The second method is the window method, how does it work?</p><p>You need to take a number of points, in the previous case 20, compute the mean (no difference with the previous method), this point it’s the beginning of the new time series and it is at the position 20 (shift of 19 points). But, instead of shifting to the next 20 points, the window is shifted by one point, compute the mean with the 20 previous points and move again and again by just shifting one step ahead. It’s not a downsampling method but a cleaning method because the effect is to smooth the data points.</p><p>Let’s see it in code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eae454c017ad640efed4865a555c74df/href">https://medium.com/media/eae454c017ad640efed4865a555c74df/href</a></iframe><p>You can easily use it like that:</p><pre># reduce the number of points with the mean on 20 points<br>x, y, y_err  = mean_sliding_windows(df.index,df[&quot;001724719_rscl&quot;], 40)</pre><p>df.index correspond to the time of the time series<br>df[“001724719_rscl”] rescaled flux of the star (“001724719”)<br>lag=40 is the number of points where the mean and the std will be computed</p><p>Now, look at the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GdyFVrWzYFiX7CT7SSbMcg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PNwFWJb0_VX_mRlngl1XZw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*__UICVMgBhwE0VLM6kru1w.png" /><figcaption>Lightcurves of the 3 previous stars with the window method showing the points between 25,000 and 30,000 measures</figcaption></figure><p>Well, not so bad. Setting the lag to 40 permits to “predict” or extend the new time series in the small holes. But, if you look closer you’ll see a divergence at the beginning and the end of the portions of the red line. The function can be improved to avoid these artifacts.</p><p>For the rest of the study, we will use the time series obtained with the moving average method.</p><p><strong><em>Change the x-axis from values to dates:</em></strong></p><p>You can change the axis if you want with dates. The Kepler mission began on 2009–03–07 and ended in 2017. <a href="https://pandas.pydata.org/"><em>Pandas</em> </a>has a function called pd.data_range() this function that allows you to create dates from a list constantly incrementing.</p><p>df.index = pd.date_range(‘2009–03–07’, periods=len(df.index), freq=’h’)</p><p>This line of code will create a new index with a frequency of hours. If you print the result (as below) you’ll find a proper real timescale.</p><pre>$ df.index<br>DatetimeIndex([&#39;2009-03-07 00:00:00&#39;, &#39;2009-03-07 01:00:00&#39;,<br>               &#39;2009-03-07 02:00:00&#39;, &#39;2009-03-07 03:00:00&#39;,<br>               &#39;2009-03-07 04:00:00&#39;, &#39;2009-03-07 05:00:00&#39;,<br>               &#39;2009-03-07 06:00:00&#39;, &#39;2009-03-07 07:00:00&#39;,<br>               &#39;2009-03-07 08:00:00&#39;, &#39;2009-03-07 09:00:00&#39;,<br>               ...<br>               &#39;2017-04-29 17:00:00&#39;, &#39;2017-04-29 18:00:00&#39;,<br>               &#39;2017-04-29 19:00:00&#39;, &#39;2017-04-29 20:00:00&#39;,<br>               &#39;2017-04-29 21:00:00&#39;, &#39;2017-04-29 22:00:00&#39;,<br>               &#39;2017-04-29 23:00:00&#39;, &#39;2017-04-30 00:00:00&#39;,<br>               &#39;2017-04-30 01:00:00&#39;, &#39;2017-04-30 02:00:00&#39;],<br>              dtype=&#39;datetime64[ns]&#39;, length=71427, freq=&#39;H&#39;)</pre><p>You have now a good timescale for the original time series.</p><p><strong><em>Generate the datasets</em></strong></p><p>So, now that the data reduction functions have been created, we can combine them in another function (shown below) which will take into account the initial dataset and the name of the stars present in the dataset (this part could have been done in the function).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1c85192adb30e88a1e09af01ae47f05/href">https://medium.com/media/f1c85192adb30e88a1e09af01ae47f05/href</a></iframe><p>To generate the new data frames do this:</p><pre>stars = df.columns<br>stars = list(set([i.split(&quot;_&quot;)[0] for i in stars]))<br>print(f&quot;The number of stars available is: {len(stars)}&quot;)<br>&gt; The number of stars available is: 13</pre><p>We have 13 stars with 4 data types, corresponding to 52 columns.</p><pre>df_mean, df_slide = reduced_data(df,stars)</pre><p>Perfect, at this point, you have two new datasets containing the data reduced by the moving average and the window method.</p><h4>Methods</h4><p><strong><em>Prepare the data:</em></strong></p><p>In order to use a machine-learning algorithm to predict time series, the data must be prepared accordingly. The data cannot just be set at (x,y) data points. The data must take the form of a series [x1, x2, x3, …, xn] and a predicted value y.</p><p>The function below shows you how to set up your dataset:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c79723afe796d34c7aef7d187462986/href">https://medium.com/media/2c79723afe796d34c7aef7d187462986/href</a></iframe><p>Two important things before starting.</p><p><em>1- The data need to be rescaled</em><br>Deep Learning algorithms are better when the data is in the range of [0, 1) to predict time series. To do it simply <a href="https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.MinMaxScaler.html">scikit-learn</a> provides the function <a href="https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.MinMaxScaler.html">MinMaxScaler</a>(). You can configure the feature_range parameter but by default it takes (0, 1). And clean the data of nan values (if you don’t delete the nan values your loss function will be output nan).</p><pre><strong><em># normalize the dataset </em></strong><br>num = 2 <strong><em># choose the third star in the dataset</em></strong><br>values = df_model[stars[num]+&quot;_rscl_y&quot;].values <strong><em># extract the list of values</em></strong><br>scaler = MinMaxScaler(feature_range=(0, 1)) <strong><em># make an instance of MinMaxScaler</em></strong><br>dataset = scaler.fit_transform(values[~np.isnan(values)].reshape(-1, 1)) <strong><em># the data will be clean of nan values, rescaled and reshape</em></strong></pre><p><em>2- The data need to be converted into x list and y <br></em>Now,<em> </em>we will the create_values() function to generate the data for the models. But, before, I prefer to save the original data by:</p><p>df_model = df_mean.save()</p><pre><strong><em># split into train and test sets</em></strong><br>train_size = int(len(dataset) * 0.8)   <strong><em># make 80% data train</em></strong><br>train = dataset[:train_size] <strong><em># set the train data</em></strong><br>test  = dataset[train_size:] <strong><em># set the test data </em></strong><br><strong><em># reshape into X=t and Y=t+1<br></em></strong>look_back = 20<br>trainX, trainY = create_dataset(train, look_back)<br>testX, testY = create_dataset(test, look_back)<br><strong><em># reshape input to be [samples, time steps, features]</em></strong><br>trainX = np.reshape(trainX, (trainX.shape[0], trainX.shape[1], 1))<br>testX = np.reshape(testX, (testX.shape[0], testX.shape[1], 1))</pre><p>Just take a look at the result:</p><pre>trainX[0]<br>&gt; array([[0.7414906],<br>       [0.76628096],<br>       [0.79901113],<br>       [0.62779976],<br>       [0.64012722],<br>       [0.64934765],<br>       [0.68549234],<br>       [0.64054092],<br>       [0.68075644],<br>       [0.73782449],<br>       [0.68319294],<br>       [0.64330245],<br>       [0.61339268],<br>       [0.62758265],<br>       [0.61779702],<br>       [0.69994317],<br>       [0.64737128],<br>       [0.64122564],<br>       [0.62016833],<br>       [0.47867125]]) <strong><em># 20 values in the first value of x train data<br></em></strong>trainY[0]<br>&gt;<strong><em> </em></strong>array([0.46174275]) <strong><em># the corresponding y value</em></strong></pre><p><strong><em>Metrics</em></strong></p><p>What metrics do we use for time series prediction? We can use the mean absolute error and the mean squared error. They are given by the function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d88c2280c9f6b11356370ab982f5ebed/href">https://medium.com/media/d88c2280c9f6b11356370ab982f5ebed/href</a></iframe><p>You need to first import the functions:</p><pre>from sklearn.metrics import mean_absolute_error, mean_squared_error</pre><p><strong><em>RNNs:</em></strong></p><p>You can implement easily the RNN family with <a href="https://keras.io/">Keras </a>in few lines of code. Here you can use this function which will configure your RNN. You need to first import the different models from Keras like:</p><pre><strong><em># import some packages</em></strong><br>import tensorflow as tf<br>from keras.layers import SimpleRNN, LSTM, GRU, Bidirectional, Conv1D, MaxPooling1D, Dropout</pre><p>Now, we have the models imported from Keras. The function below can generate a simple model (SimpleRNN, LSTM, GRU). Or, two models (identical) can be stacked, or used in Bidirectional or a stack of two Bidirectional models. You can also add the CNN part (Conv1D)with MaxPooling1D and dropout.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ffce2c43732c27b68a439f603af6be3/href">https://medium.com/media/0ffce2c43732c27b68a439f603af6be3/href</a></iframe><p>This function computes the metrics for the training part and the test part and returned the results in a data frame. Look at how you how to use it for five examples.</p><p>LSTM:</p><pre><strong><em># train the model and compute the metrics</em></strong><br>&gt; x_train_predict_lstm, y_train_lstm,x_test_predict_lstm, y_test_lstm, res= <strong>time_series_deep_learning</strong>(train_x, train_y, test_x, test_y, model_dl=<strong>LSTM </strong>,  unit=12, look_back=20)<br><strong><em># plot the resuts of the prediction</em></strong><br>&gt; plotting_predictions(dataset, look_back, x_train_predict_lstm,  x_test_predict_lstm)<br><strong><em># save the metrics per model in the dataframe df_results</em></strong><br>&gt; df_results = df_results.append(res)</pre><p>GRU:</p><pre><strong><em># train the model and compute the metrics</em></strong><br>&gt; x_train_predict_lstm, y_train_lstm,x_test_predict_lstm, y_test_lstm, res= <strong>time_series_deep_learning</strong>(train_x, train_y, test_x, test_y, model_dl=<strong>GRU</strong>,  unit=12, look_back=20)</pre><p>Stack LSTM:</p><pre><strong><em># train the model and compute the metrics</em></strong><br>&gt; x_train_predict_lstm, y_train_lstm,x_test_predict_lstm, y_test_lstm, res= <strong>time_series_deep_learning</strong>(train_x, train_y, test_x, test_y, model_dl=<strong>LSTM </strong>,  unit=12, look_back=20, <strong>stacked=True</strong>)</pre><p>Bidirectional LSTM:</p><pre><strong><em># train the model and compute the metrics</em></strong><br>&gt; x_train_predict_lstm, y_train_lstm,x_test_predict_lstm, y_test_lstm, res= <strong>time_series_deep_learning</strong>(train_x, train_y, test_x, test_y, model_dl=<strong>LSTM </strong>,  unit=12, look_back=20, <strong>bidirection=True</strong>)</pre><p>CNN-LSTM:</p><pre><strong><em># train the model and compute the metrics</em></strong><br>&gt; x_train_predict_lstm, y_train_lstm,x_test_predict_lstm, y_test_lstm, res= <strong>time_series_deep_learning</strong>(train_x, train_y, test_x, test_y, model_dl=<strong>LSTM </strong>,  unit=12, look_back=20, <strong>cnn=True</strong>)</pre><h4>Results</h4><p>The results are pretty good considering the data. We can see that deep learning RNN can reproduce with good accuracy of the data. The figure below shows the result of the prediction by the LSTM model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_dFLAin8fHnbENhG2hYXSw.png" /><figcaption>LSTM predictions</figcaption></figure><p><em>Table 1: Results of the different RNN models, showing the MAE and MSE metrics</em></p><pre>        Name    | MAE Train | MSE Train | MAE Test | MSE Test<br>--------------------------------------------------------------------<br>            GRU |   4.24    |   34.11   |   4.15   |   31.47 <br>           LSTM |   4.26    |   34.54   |   4.16   |   31.64 <br>      Stack_GRU |   4.19    |   33.89   |   4.17   |   32.01<br>      SimpleRNN |   4.21    |   34.07   |   4.18   |   32.41<br>           LSTM |   4.28    |   35.1    |   4.21   |   31.9<br>         Bi_GRU |   4.21    |   34.34   |   4.22   |   32.54<br>  Stack_Bi_LSTM |   4.45    |   36.83   |   4.24   |   32.22<br>        Bi_LSTM |   4.31    |   35.37   |   4.27   |   32.4<br>Stack_SimpleRNN |   4.4     |   35.62   |   4.27   |   33.94<br>      SimpleRNN |   4.44    |   35.94   |   4.31   |   34.37 <br>     Stack_LSTM |   4.51    |   36.78   |   4.4    |   34.28<br> Stacked_Bi_GRU |   4.56    |   37.32   |   4.45   |   35.34<br>       CNN_LSTM |   5.01    |   45.85   |   4.55   |   36.29<br>        CNN_GRU |   5.05    |   46.25   |   4.66   |   37.17 <br>  CNN_Stack_GRU |   5.07    |   45.92   |   4.7    |   38.64</pre><p>The Table 1 shows the mean absolute error (MAE) and the mean squared error (MSE) for the train set and the test set for the RNN family. The GRU shows the best result on the test set with an MAE of 4.15 and an MSE of 31.47.</p><h4>Discussion</h4><p>The results are good and reproduced the lightcurves of the different stars (see notebook). However, the fluctuations are not perfectly reproduced, the peaks do not have the same intensity and the flux is slightly shifted. A potential correction could be made via the attention mechanisms (Transformers[10]). Another way is to tune the models, the number of layers (stack), the number of units (cells), the combination of different RNN algorithms, new loss function or activation function, etc.</p><h4>Conclusion</h4><p>This article shows the possibilities of combining so-called artificial intelligence methods with time series. The power of memory algorithms (RNN, LSTM, GRU) makes it possible to accurately reproduce sporadic fluctuations of events. In our case, the stellar flux exhibited quite strong and marked fluctuations that the methods have been able to capture.</p><p>This study shows that time series are no longer reserved for statistical methods such as the ARIMA[4] model.</p><h4>References</h4><p>[1] <a href="https://en.wikipedia.org/wiki/Autoregressive_model">Autoregressive model, Wikipedia</a><br>[2] <a href="https://en.wikipedia.org/wiki/Moving-average_model">Moving-average model, Wikipedia</a><br>[3] Peter Whittle, 1950. <em>Hypothesis testing in time series analysis. </em>Thesis<br>[4] Alberto Luceño &amp; Daniel Peña, 2008. <em>Autoregressive Integrated Moving Average (ARIMA) Modeling</em>. Wiley Online Library. <a href="https://doi.org/10.1002/9780470061572.eqr276">https://doi.org/10.1002/9780470061572.eqr276</a><br>[5] Rumelhart, David E. <em>et al.</em>, 1986. <em>Learning representations by back-propagating errors</em>. <em>Nature</em>. <strong>323</strong> (6088): 533–536. <a href="https://ui.adsabs.harvard.edu/abs/1986Natur.323..533R">1986Natur.323..533R</a>. <br>[6] Hochreiter, Sepp &amp; Schmidhuber, Jürgen, 1997. <em>Long Short-Term Memory</em>. <em>Neural Computation</em>. <strong>9</strong> (8): 1735–1780. <a href="https://en.wikipedia.org/wiki/Doi_(identifier)">doi</a>:<a href="https://doi.org/10.1162%2Fneco.1997.9.8.1735">10.1162/neco.1997.9.8.1735</a><br>[7] Cho, KyungHyun <em>et al.</em>, 2014. <em>Empirical Evaluation of Gated Recurrent Neural Networks on Sequence Modeling</em>. <a href="https://en.wikipedia.org/wiki/ArXiv_(identifier)">arXiv</a>:<a href="https://arxiv.org/abs/1412.3555">1412.3555</a><br>[8] M. Schuster &amp; K.K. Paliwal, 1997. <em>Bidirectional recurrent neural</em> networks. IEEE Transactions on Signal Processing, Volume: 45 , Issue: 11, pp. 2673–2681. DOI<strong>: </strong><a href="https://doi.org/10.1109/78.650093">10.1109/78.650093</a><br>[9] Tara N. Sainath <em>et al.</em>, 2014. <em>CONVOLUTIONAL, LONG SHORT-TERM MEMORY,FULLY CONNECTED DEEP NEURAL NETWORKS</em>. <a href="https://static.googleusercontent.com/media/research.google.com/fr//pubs/archive/43455.pdf">https://static.googleusercontent.com/media/research.google.com/fr//pubs/archive/43455.pdf</a><br>[10] Ashish Vaswani <em>et al.</em>, 2017. Attention is all you need. <a href="https://arxiv.org/abs/1706.03762">https://arxiv.org/abs/1706.03762</a><br>[11] <a href="https://www.nasa.gov/mission_pages/kepler/overview/index.html">Kepler mission, Nasa</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f8a399cf205" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/how-to-use-deep-learning-for-time-series-forecasting-3f8a399cf205">How to use Deep Learning for Time Series Forecasting</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>