Tensorflow(TF) Quantum - Application

Problem Overview

Computer Vision Digit Recognizer

Kaggle Problem reference - https://www.kaggle.com/c/digit-recognizer/

Goal - The goal in this competition is to take an image of a handwritten single digit, and determine what that digit is. For every in the test set, you should predict the correct label.

Metric - This competition is evaluated on the categorization accuracy of your predictions (the percentage of images you get correct).

Submission File Format -The file should contain a header and have the following format:

ImageId     ,       Label

1 0

Overview - Data Description

The data files train.csv and test.csv contain gray-scale images of hand-drawn digits, from zero through nine. Each image is 28 pixels in height and 28 pixels in width, for a total of 784 pixels in total. Each pixel has a single pixel-value associated with it, indicating the lightness or darkness of that pixel, with higher numbers meaning darker. This pixel-value is an integer between 0 and 255, inclusive.

The training data set, (train.csv), has 785 columns. The first column, called "label", is the digit that was drawn by the user. The rest of the columns contain the pixel-values of the associated image.

Each pixel column in the training set has a name like pixel x, where x is an integer between 0 and 783, inclusive. To locate this pixel on the image, suppose that we have decomposed x as x = i * 28 + j, where i and j are integers between 0 and 27, inclusive. Then pixel x is located on row i and column j of a 28 x 28 matrix, (indexing by zero).

Solution - Approach

Solution-1 - TFQ -TensorFlow Quantum 

Solution-2 - Keras Conv2D and Max pooling

Solution-1

TensorFlow Quantum

“Nature isn’t classical, damnit, so if you want to make a simulation of nature, you’d better make it quantum mechanical.” — Physicist  - Richard Feynman

Qubit can store a single bit – the smallest possible unit of digital information – and is the fundamental building block of a future quantum computer

No alt text provided for this image


Two qubits: Now let us examine a system of two qubits. Consider the two electrons in two hydrogen atoms, each regarded as a 2-state quantum system: + 0 1 + 0 1 Since each electron can be in either of the ground or excited state, classically the two electrons are in one of four states – 00, 01, 10, or 11 – and represent 2 bits of classical information. By the superposition principle, the quantum state of the two electrons can be any linear combination of these four classical states:  

ψ = α00 |00| + α01 |01| +α10  10 +α11  11

, where αi j ∈C, ∑i j |αi j| 2 = 1. Again, this is just Dirac notation for the unit vector in C 4 :   α00 α01 α10 α11  

TFQ contains the basic structures, such as qubits, gates, circuits, and measurement operators that are required for specifying quantum computations.

What is a Quantum ML Model?

A quantum model has the ability to represent and generalize data with a quantum mechanical origin.Quantum data exhibits superposition and entanglement, leading to joint probability distribution

Steps for TFQ

  1. Prepare a quantum dataset 
  2. Evaluate a quantum neural network model 
  3. Sample or Average
  4. Evaluate a classical neural networks model 
  5. Evaluate Cost Function 
  6. Evaluate Gradients & Update Parameters

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Solution-2

Keras Conv2D and Max pooling

No alt text provided for this image

Results - keras Conv2D and Max pooling

No alt text provided for this image


To view or add a comment, sign in

More articles by Kunal U

Others also viewed

Explore content categories