QuantumFlow Demo (1) --- Classify 3 and 6 in MNIST

QF-Net:

Layer 1:

Neural 1:
[1., 1., 1., 1., 1., 1., 1., -1., 1., -1., 1., -1., 1., 1., 1., 1.]
Neural 2:
[-1., -1., -1., -1., -1., -1., -1., -1., -1., 1., -1., 1., -1., -1.,-1., -1.]

Layer 2:

Neural 1:
[ 1., -1.]
Neural 2:
[-1., -1.]

BN for Layer 2:

Neural 1:
lt 0.5; 0.3060
Neural 2:
gt 0.5: 0.6940

Accuracy:

95.73% for MNIST with input downsampled to 4*4

QF-Circ:

QF-Circ Implementation in Quirk, based on the trained model of QF-Net

Quirk link of the circuit without inputs

Input Generator

github link (to be updated)

First Example: image 3_0:

Quirk link of example 3_0

Inputs Conversion

Original Data in MNIST 3_0 (4X larger)
Downsampled Image of 3_0 (7X larger)

Unitray Matrix Built upon 3_0 to Quantum Input
0.1495317816734314,-0.28838270902633667,-0.09612756967544556,0.0,-0.25099977850914,-0.3150848150253296,-0.41121238470077515,-0.032042521983385086,0.0,-0.0747658908367157,-0.5180208086967468,-0.17623388767242432,0.0,-0.25099977850914,-0.42723366618156433,-0.04806378483772278,
0.28838270902633667,0.9276534914970398,-0.02411549724638462,0.0,-0.06296823918819427,-0.07904523611068726,-0.10316073894500732,-0.00803849846124649,0.0,-0.018756497651338577,-0.1299557238817215,-0.044211745262145996,0.0,-0.06296823918819427,-0.10717998445034027,-0.01205774862319231,
0.09612756967544556,-0.02411549724638462,0.9919614791870117,0.0,-0.020989414304494858,-0.0263484138995409,-0.03438691422343254,-0.0026794997975230217,0.0,-0.006252165883779526,-0.043318577110767365,-0.014737248420715332,0.0,-0.020989414304494858,-0.03572666272521019,-0.0040192496962845325,
0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
0.25099977850914,-0.06296823918819427,-0.020989414304494858,0.0,0.9451943039894104,-0.06879863142967224,-0.0897880494594574,-0.006996471434831619,0.0,-0.016325099393725395,-0.11310961842536926,-0.038480594754219055,0.0,-0.0548056922852993,-0.09328628331422806,-0.010494707152247429,
0.3150848150253296,-0.07904523611068726,-0.0263484138995409,0.0,-0.06879863142967224,0.9136357307434082,-0.11271265894174576,-0.008782804012298584,0.0,-0.02049320936203003,-0.14198866486549377,-0.04830542579293251,0.0,-0.06879863142967224,-0.11710406094789505,-0.01317420694977045,
0.41121238470077515,-0.10316073894500732,-0.03438691422343254,0.0,-0.0897880494594574,-0.11271265894174576,0.8529004454612732,-0.011462303809821606,0.0,-0.026745375245809555,-0.18530724942684174,-0.06304267793893814,0.0,-0.0897880494594574,-0.15283071994781494,-0.01719345711171627,
0.032042521983385086,-0.00803849846124649,-0.0026794997975230217,0.0,-0.006996471434831619,-0.008782804012298584,-0.011462303809821606,0.9991068243980408,0.0,-0.0020840552169829607,-0.01443952601402998,-0.004912415985018015,0.0,-0.006996471434831619,-0.011908886954188347,-0.0013397498987615108,
0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
0.0747658908367157,-0.018756497651338577,-0.006252165883779526,0.0,-0.016325099393725395,-0.02049320936203003,-0.026745375245809555,-0.0020840552169829607,0.0,0.9951372146606445,-0.03369222581386566,-0.011462303809821606,0.0,-0.016325099393725395,-0.027787404134869576,-0.003126082941889763,
0.5180208086967468,-0.1299557238817215,-0.043318577110767365,0.0,-0.11310961842536926,-0.14198866486549377,-0.18530724942684174,-0.01443952601402998,0.0,-0.03369222581386566,0.766560971736908,-0.0794173926115036,0.0,-0.11310961842536926,-0.19252701103687286,-0.021659288555383682,
0.17623388767242432,-0.044211745262145996,-0.014737248420715332,0.0,-0.038480594754219055,-0.04830542579293251,-0.06304267793893814,-0.004912415985018015,0.0,-0.011462303809821606,-0.0794173926115036,0.9729816913604736,0.0,-0.038480594754219055,-0.06549888104200363,-0.007368624210357666,
0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,
0.25099977850914,-0.06296823918819427,-0.020989414304494858,0.0,-0.0548056922852993,-0.06879863142967224,-0.0897880494594574,-0.006996471434831619,0.0,-0.016325099393725395,-0.11310961842536926,-0.038480594754219055,0.0,0.9451943039894104,-0.09328628331422806,-0.010494707152247429,
0.42723366618156433,-0.10717998445034027,-0.03572666272521019,0.0,-0.09328628331422806,-0.11710406094789505,-0.15283071994781494,-0.011908886954188347,0.0,-0.027787404134869576,-0.19252701103687286,-0.06549888104200363,0.0,-0.09328628331422806,0.8412148356437683,-0.017863331362605095,
0.04806378483772278,-0.01205774862319231,-0.0040192496962845325,0.0,-0.010494707152247429,-0.01317420694977045,-0.01719345711171627,-0.0013397498987615108,0.0,-0.003126082941889763,-0.021659288555383682,-0.007368624210357666,0.0,-0.010494707152247429,-0.017863331362605095,0.9979903697967529

Results

Results: the input 3_0 is generated using the above unitray matrix

Prob(Img=”3”)=63.7% (Correct)
Prob(Img=”6”)=36.3%

Second Example: image 3_1:

Inputs Conversion

Original Data in MNIST 3_1 (4X larger)
Downsampled Image of 3_1 (7X larger)

Results

Prob(Img=”3”)=61.5% (Correct)
Prob(Img=”6”)=38.5%

Thrid Example: image 6_0:

Inputs Conversion

Original Data in MNIST 6_0 (4X larger)
Downsampled Image of 6_0 (7X larger)

Results

Prob(Img=”3”)=44.8%
Prob(Img=”6”)=55.2% (Correct)

Fourth Example: image 6_1:

Inputs Conversion

Original Data in MNIST 6_1 (4X larger)
Downsampled Image of 6_1 (7X larger)

Results

Prob(Img=”3”)=43.8%
Prob(Img=”6”)=56.2% (Correct)

Quirk with all inputs



Aug. 04, 2020
Weiwen Jiang
wjiang2@nd.edu