DataEncoding_EN.ipynb 20.0 KB
Notebook
Newer Older
Q
Quleaf 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "2b8d96ea",
   "metadata": {},
   "source": [
    "# Encoding Classical Data into Quantum States\n",
    "\n",
    "<em> Copyright (c) 2021 Institute for Quantum Computing, Baidu Inc. All Rights Reserved. </em>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f160535c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>pre { white-space: pre !important; }</style>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from IPython.core.display import HTML\n",
    "display(HTML(\"<style>pre { white-space: pre !important; }</style>\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2e2ccb8d",
   "metadata": {},
   "source": [
    "## Overview\n",
    "\n",
    "Quantum encoding is a process to transform classical information into quantum states. \n",
    "It plays a crucial role in using quantum algorithms to solve classical problems, especially in quantum machine learning tasks. Interested readers can find an example of using quantum encoding \n",
    "in our tutorial on [quantum classifier](./QClassifier_EN.ipynb), where we use quantum neural networks to accomplish a classical binary classification task.\n",
    "Quantum encoding can be seen as a quantum circuit that acts on $\\left| 0^n \\right>$ state (n is the number of qubits), with some parameters determined by the classical information.\n",
    "\n",
    "In this tutorial, we will discuss five typical encoding schemes, including **basis encoding** [1], **amplitude encoding** [1], **angle encoding** [1], **instantaneous quantum polynomial (IQP) style encoding** [2], and **Hamiltonian evolution ansatz encoding** [3]. In Paddle Quantum, we provide built-in methods for the first four encoding strategies.\n",
    "\n",
    "## Basis Encoding\n",
    "\n",
    "Basis encoding is the most intuitive way to encode classical information into a quantum state. It encodes an $n$-bit binary string $x$ to an $n$-qubit quantum state $\\left|x\\right> = \\left|i_x\\right>$, where $\\left|i_x\\right>$ is a computational basis state. For example, if $x=1011$, the corresponding quantum state after basis encoding is $\\left|1011\\right>$. Let's take a look at how to use Paddle Quantum to implement basis encoding:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3b220934",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Import necessary library\n",
    "import paddle\n",
    "from paddle_quantum.circuit import UAnsatz\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9e653bdf",
   "metadata": {},
   "source": [
    "Start from $\\left| 0^n \\right>$, and we apply an $X$ gate if the corresponding classical bit is 1. We construct the circuit as follows: "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "ff86f454",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--X--\n",
      "     \n",
      "-----\n",
      "     \n",
      "--X--\n",
      "     \n",
      "--X--\n",
      "     \n"
     ]
    }
   ],
   "source": [
    "# Number of qubits = length of the classical binary string\n",
    "n = 4\n",
    "# Initialize the circuit\n",
    "basis_enc = UAnsatz(n)\n",
    "# X is the classical information\n",
    "x = '1011'\n",
    "# Add a Pauli X gate to the ith qubit if the ith classical bit is 1\n",
    "for i in range(len(x)):\n",
    "    if x[i] == '1':\n",
    "        basis_enc.x(i)\n",
    "        \n",
    "print(basis_enc)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "95559773",
   "metadata": {},
   "source": [
    "The corresponding quantum state after basis encoding is: "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9a5909db",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j\n",
      " 0.+0.j 1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j]\n"
     ]
    }
   ],
   "source": [
    "basis_quan_state = basis_enc.run_state_vector()\n",
    "print(basis_quan_state.numpy())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a6360824",
   "metadata": {},
   "source": [
    "which is the state $\\left|1011\\right>$ as we desired.\n",
    "\n",
    "In Paddle Quantum, we also provide a built-in method for basis encoding:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a7594453",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j\n",
      " 0.+0.j 1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j]\n"
     ]
    }
   ],
   "source": [
    "# Built-in basis encoding\n",
    "built_in_basis_enc = UAnsatz(n)\n",
    "# Classical information x should be of type Tensor\n",
    "x = paddle.to_tensor([1, 0, 1, 1])\n",
    "built_in_basis_enc.basis_encoding(x)\n",
    "built_in_basis_enc_state = built_in_basis_enc.run_state_vector()\n",
    "print(built_in_basis_enc_state.numpy())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0630a047",
   "metadata": {},
   "source": [
    "## Amplitude Encoding\n",
    "\n",
    "Amplitude encoding encodes a vector $\\mathbf{x}$ of length $N$ into amplitudes of an $n$-qubit quantum state with $n = \\lceil\\log_2(N)\\rceil$:\n",
    "\n",
    "$$\n",
    "\\begin{align*} \\left|\\mathbf{x}\\right> = \\sum\\limits_{i}^{N}x_i\\left|i\\right>\\end{align*},\n",
    "$$\n",
    "\n",
    "where $\\left\\{\\left|i\\right>\\right\\}$ is the computational basis for the Hilbert space. Since the classical information forms the amplitudes of a quantum state, the input needs to satisfy the normalization condition: $\\left|\\mathbf{x}\\right|^{2} = 1$.\n",
    "\n",
    "For instance, if $\\mathbf{x} = \\begin{bmatrix} \\frac{1}{2}\\\\ \\frac{1}{2}\\\\ -\\frac{1}{2}\\\\ -\\frac{1}{2} \\end{bmatrix}$, the corresponding quantum state will be $\\left|\\mathbf{x}\\right> = \\frac{1}{2}\\left|00\\right> + \\frac{1}{2} \\left|01\\right> - \\frac{1}{2} \\left|10\\right> - \\frac{1}{2} \\left|11\\right>$.  \n",
    "Here is another example with $N < 2^n$, if $\\mathbf{y} = \\begin{bmatrix} \\frac{1}{\\sqrt{3}}\\\\\\frac{1}{\\sqrt{3}}\\\\\\frac{1}{\\sqrt{3}} \\end{bmatrix}$, the corresponding quantum state will be $\\left|\\mathbf{y}\\right> = \\frac{1}{\\sqrt{3}}\\left|00\\right> + \\frac{1}{\\sqrt{3}}\\left|01\\right> + \\frac{1}{\\sqrt{3}}\\left|10\\right>$.\n",
    "\n",
    "You may have already noticed, amplitude encoding cannot be represented as a trivial quantum circuit. Instead, it can be implemented using arbitrary state preparation [1]. But don't worry. In Paddle Quantum, we provide a built-in method for amplitude encoding:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "adb251b5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.57735026+0.j 0.57735026+0.j 0.57735026+0.j 0.        +0.j]\n"
     ]
    }
   ],
   "source": [
    "# Built-in amplitude encoding\n",
    "# Number of qubits = 2\n",
    "n = 2\n",
    "# Initialize the circuit\n",
    "built_in_amplitude_enc = UAnsatz(n)\n",
    "# Classical information x should be of type Tensor\n",
    "x = paddle.to_tensor([0.5, 0.5, 0.5])\n",
    "state = built_in_amplitude_enc.amplitude_encoding(x, 'state_vector')\n",
    "print(state.numpy())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a90d9ca6",
   "metadata": {},
   "source": [
    "In Paddle Quantum, we will normalize the input classical vector by default. As you can see, \n",
    "the result is indeed $\\frac{1}{\\sqrt{3}}\\left|00\\right> + \\frac{1}{\\sqrt{3}}\\left|01\\right> + \\frac{1}{\\sqrt{3}}\\left|10\\right>$.\n",
    "\n",
    "## Angle Encoding\n",
    "\n",
    "Angle encoding makes use of rotation gates to encode classical information $\\mathbf{x}$. The classical information determines angles of rotation gates:\n",
    "\n",
    "$$\n",
    "\\left|\\mathbf{x}\\right> = \\bigotimes_{i}^{n} R(\\mathbf{x}_i) \\left| 0^n \\right>,\n",
    "$$\n",
    "\n",
    "where $R$ can be one of $R_x$, $R_y$, $R_z$. Usually, the number of qubits used for encoding is equal to the dimension of vector $\\mathbf{x}$.  \n",
    "For example, when $\\mathbf{x} = \\begin{bmatrix} \\pi \\\\ \\pi\\\\ \\pi \\end{bmatrix}$, angle encoding rotates every qubit around Y-axis (if we choose $R_y$) for degree $\\pi$, so that the corresponding quantum state will be $\\left|111\\right>$.\n",
    "\n",
    "The circuit for angle encoding can be constructed as follows: "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "5f9c513e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--Ry(3.142)--\n",
      "             \n",
      "--Ry(3.142)--\n",
      "             \n",
      "--Ry(3.142)--\n",
      "             \n"
     ]
    }
   ],
   "source": [
    "# Number of qubits = length of the classical information\n",
    "n = 3\n",
    "# Initialize the circuit\n",
    "angle_enc = UAnsatz(n)\n",
    "# X is the classical information\n",
    "x = paddle.to_tensor([np.pi, np.pi, np.pi], 'float64')\n",
    "# Add a layer of rotation y gates\n",
    "for i in range(len(x)):\n",
    "    angle_enc.ry(x[i], i)\n",
    "        \n",
    "print(angle_enc)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1e5a6e06",
   "metadata": {},
   "source": [
    "The corresponding quantum state after amplitude encoding is:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "295e7c3d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0j, 0j, 0j, 0j, 0j, 0j, 0j, (1+0j)]\n"
     ]
    }
   ],
   "source": [
    "angle_quan_state = angle_enc.run_state_vector()\n",
    "print([np.round(i, 2) for i in angle_quan_state.numpy()])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c13e7bf8",
   "metadata": {},
   "source": [
    "The corresponding state is $\\left|111\\right>$ as we desired.\n",
    "\n",
    "In Paddle Quantum, we also provide a built-in method for angle encoding:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "af779e74",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0j, 0j, 0j, 0j, 0j, 0j, 0j, (1+0j)]\n"
     ]
    }
   ],
   "source": [
    "# Built-in angle encoding\n",
    "# Number of qubits\n",
    "n = 3\n",
    "# Initialize the circuit\n",
    "built_in_angle_enc = UAnsatz(n)\n",
    "# Classical information x should be of type Tensor\n",
    "x = paddle.to_tensor([np.pi, np.pi, np.pi], 'float64')\n",
    "built_in_angle_enc.angle_encoding(x, \"ry\")\n",
    "state = built_in_angle_enc.run_state_vector()\n",
    "print([np.round(i, 2) for i in state.numpy()])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "94d09e5f",
   "metadata": {},
   "source": [
    "## IQP Style Encoding\n",
    "\n",
    "IQP style encoding is a relatively complicated encoding strategy. We encode classical information $\\mathbf{x}$ to \n",
    "\n",
    "$$\n",
    "\\left|\\mathbf{x}\\right> = \\left(\\mathrm{U}_\\mathrm{Z}(\\mathbf{x})\\mathrm{H}^{\\otimes n}\\right)^{r}\\left|0^n\\right>,\n",
    "$$\n",
    "\n",
    "where $r$ is the depth of the circuit, indicating the repeating times of $\\mathrm{U}_\\mathrm{Z}(\\mathbf{x})\\mathrm{H}^{\\otimes n}$. $\\mathrm{H}^{\\otimes n}$ is a layer of Hadamard gates acting on all qubits. $\\mathrm{U}_\\mathrm{Z}(\\mathbf{x})$ is the key step in IQP encoding scheme:\n",
    "\n",
    "$$\n",
    "\\mathrm{U}_\\mathrm{Z}(\\mathbf{x})=\\prod\\limits_{[i,j]\\in S}R_{Z_iZ_j}(x_ix_j)\\bigotimes_{k=1}^{n} R_z(x_k),\n",
    "$$\n",
    "\n",
    "where $S$ is the set containing all pairs of qubits to be entangled using $R_{ZZ}$ gates.\n",
    "\n",
    "First, we consider a simple two-qubit gate: $R_{Z_1Z_2}(\\theta)$. Its mathematical form $e^{-i\\frac{\\theta}{2}Z_1\\otimes Z_2}$ can be seen as a two-qubit rotation gate around ZZ , which makes these two qubits entangled. \n",
    "One can implement this gate using Paddle Quantum as follows:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "bcde1189",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--*-----------------*--\n",
      "  |                 |  \n",
      "--X----Rz(2.000)----X--\n",
      "                       \n"
     ]
    }
   ],
   "source": [
    "# Number of qubits\n",
    "n = 2\n",
    "# Initialize the circuit\n",
    "Rzz = UAnsatz(n)\n",
    "# Theta is the angle of Rzz gate\n",
    "theta = paddle.to_tensor([2], 'float64')\n",
    "# Implement Rzz gate\n",
    "Rzz.cnot([0, 1])\n",
    "Rzz.rz(theta, 1)\n",
    "Rzz.cnot([0, 1])\n",
    "        \n",
    "print(Rzz)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "89c92df4",
   "metadata": {},
   "source": [
    "In $\\mathrm{U}_\\mathrm{Z}$, an $R_{ZZ}$ gate needs to be added between every pair of qubits in set $S$. In our built-in IQP encoding method, users are allowed to define their customized set $S$.\n",
    "\n",
    "Now, let's take a look at how to implement IQP encoding using Paddle Quantum:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "38f5afac",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--H----Rz(-1.45)----*-----------------*------------------------------------------------\n",
      "                    |                 |                                                \n",
      "--H----Rz(3.000)----X----Rz(-4.35)----X----*-----------------*-------------------------\n",
      "                                           |                 |                         \n",
      "--H----Rz(2.000)---------------------------X----Rz(6.000)----X----*-----------------*--\n",
      "                                                                  |                 |  \n",
      "--H----Rz(-0.05)--------------------------------------------------X----Rz(-0.10)----X--\n",
      "                                                                                       \n"
     ]
    }
   ],
   "source": [
    "# Number of qubits\n",
    "n = 4\n",
    "# Initialize the circuit\n",
    "iqp_enc = UAnsatz(n)\n",
    "# X is the classical information\n",
    "x = paddle.to_tensor([-1.45, 3, 2, -0.05], 'float64')\n",
    "# S is a list containing all the pairs to be entagled\n",
    "S = [[0, 1], [1, 2], [2, 3]]\n",
    "# r is the repeating times of U\n",
    "r = 1\n",
    "\n",
    "for i in range(r):\n",
    "    # Add a layer of hadamard gates\n",
    "    iqp_enc.superposition_layer()\n",
    "    # Add a layer of rotation z gates\n",
    "    for j in range(n):\n",
    "        iqp_enc.rz(x[j] ,j)\n",
    "    # Add a layer of ZZ gates\n",
    "    for k in S:\n",
    "        iqp_enc.cnot(k)\n",
    "        iqp_enc.rz(x[k[0]] * x[k[1]], k[1])\n",
    "        iqp_enc.cnot(k)\n",
    "            \n",
    "print(iqp_enc)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a0e60e87",
   "metadata": {},
   "source": [
    "The corresponding quantum state after IQP style encoding is:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "187b7ec4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[(0.25+0j), (0.24719-0.03736j), (-0.0115+0.24974j), (-0.02397+0.24885j), (-0.01559-0.24951j), (-0.0527-0.24438j), (0.21313+0.13067j), (0.20633+0.14116j), (0.22138+0.11615j), (0.23625+0.08176j), (-0.12621+0.2158j), (-0.13684+0.20922j), (0.07483+0.23854j), (0.10964+0.22468j), (-0.2382-0.07589j), (-0.23411-0.0877j)]\n"
     ]
    }
   ],
   "source": [
    "iqp_quan_state = iqp_enc.run_state_vector()\n",
    "print([np.round(i, 5) for i in iqp_quan_state.numpy()])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9aee1dcb",
   "metadata": {},
   "source": [
    "In Paddle Quantum, we provide a built-in IQP encoding method that exactly follows the way we explained above. However, this is just a particular case for IQP style encoding. IQP style encoding can refer \n",
    "to a more general class of encoding schemes. For example, you can replace the rotation Z gate with rotation X gate or rotation Y gate and replace $R_{ZZ}$ gate with $R_{XX}$ gate or $R_{YY}$ gate. Besides, you can think of three-qubit rotation gates, and add more layers with these three-qubit rotation gates."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "a81b03cb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[(0.25+0j), (0.24719-0.03736j), (-0.0115+0.24974j), (-0.02397+0.24885j), (-0.01559-0.24951j), (-0.0527-0.24438j), (0.21313+0.13067j), (0.20633+0.14116j), (0.22138+0.11615j), (0.23625+0.08176j), (-0.12621+0.2158j), (-0.13684+0.20922j), (0.07483+0.23854j), (0.10964+0.22468j), (-0.2382-0.07589j), (-0.23411-0.0877j)]\n"
     ]
    }
   ],
   "source": [
    "# Built-in IQP style encoding\n",
    "# Number of qubits\n",
    "n = 4\n",
    "# Initialize the circuit\n",
    "built_in_iqp_enc = UAnsatz(n)\n",
    "# Classical information x should be of type Tensor\n",
    "x = paddle.to_tensor([-1.45, 3, 2, -0.05], 'float64')\n",
    "# S is a list containing all the pairs to be entagled\n",
    "S = [[0, 1], [1, 2], [2, 3]]\n",
    "# r is the repeating times of U\n",
    "r = 1\n",
    "built_in_iqp_enc.iqp_encoding(x, r, S)\n",
    "built_in_iqp_enc_state = built_in_iqp_enc.run_state_vector()\n",
    "print([np.round(i, 5) for i in built_in_iqp_enc_state.numpy()])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "251975b7",
   "metadata": {},
   "source": [
    "## Hamiltonian Evolution Ansatz Encoding\n",
    "\n",
    "Hamiltonian evolution ansatz encoding, which uses a Trotter formula to approximate an evolution, has been explored in obtaining the ground state of a Hubbard model [4].\n",
    "\n",
    "$$\n",
    "\\left|\\mathbf{x}\\right> = \\left(\\prod\\limits_{i=1}^{n}R_{Z_iZ_{i+1}}(\\frac{t}{T}x_{i})R_{Y_iY_{i+1}}(\\frac{t}{T}x_{i})R_{X_iX_{i+1}}(\\frac{t}{T}x_{i})\\right)^{T}\\bigotimes_{i=1}^{n+1}\\left|\\psi_{i}\\right>,\n",
    "$$\n",
    "\n",
    "where $R_{XX}, R_{YY}, R_{ZZ}$ are the same rotation gates described in IQP style encoding, T is the number of Trotter steps, and $\\left|\\psi_{i}\\right>$ is a Haar-random single-qubit quantum state.\n",
    "You can implement this encoding by applying T layers of $R_{XX}, R_{YY}, R_{ZZ}$ gates to the prepared Haar-random quantum state."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b4dddb79",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "## References\n",
    "\n",
    "[1] Schuld, Maria. \"Quantum machine learning models are kernel methods.\" [arXiv:2101.11020 (2021).](https://arxiv.org/abs/2101.11020)\n",
    "\n",
    "[2] Havlíček, Vojtěch, et al. \"Supervised learning with quantum-enhanced feature spaces.\" [Nature 567.7747 (2019): 209-212.](https://www.nature.com/articles/s41586-019-0980-2)\n",
    "\n",
    "[3] Huang, Hsin-Yuan, et al. \"Power of data in quantum machine learning.\" [Nature Communications 12.1 (2021): 1-9.](https://www.nature.com/articles/s41467-021-22539-9)\n",
    "\n",
    "[4] Cade, Chris, et al. \"Strategies for solving the Fermi-Hubbard model on near-term quantum computers.\" [Physical Review B 102.23 (2020): 235122.](https://journals.aps.org/prb/abstract/10.1103/PhysRevB.102.235122)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}