5.8 Comparison of Neural Networks
5.8 Comparison of Neural Networks
5.8.1 Reconstruction Binary Digits
5.8.1 Reconstruction Binary Digits
In[]:=
testData=ResourceData["MNIST","TestData"];
In[]:=
SeedRandom[1843]
In[]:=
data=RandomSample[testData,300];
In[]:=
zero=Select[data,#[[2]]0&]
Out[]=
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
In[]:=
one=Select[data,#[[2]]1&]
Out[]=
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
In[]:=
z=Map[#[[1]]&,zero];
In[]:=
o=Map[#[[1]]&,one];
In[]:=
dr=DimensionReduction[Join[z,o],2]
Out[]=
DimensionReducerFunction
In[]:=
zz=dr[z];
In[]:=
oo=dr[o];
In[]:=
ListPlot[{zz,oo},FrameTrue]
Out[]=
In[]:=
Export["E:\\dataZero.dat",zz];
In[]:=
Export["E:\\dataOne.dat",oo];
In[]:=
ZZ=Import["E:\\dataZero.dat"];
In[]:=
OO=Import["E:\\dataOne.dat"];
In[]:=
zz=Take[ZZ,{1,16}];
In[]:=
oo=Take[OO,{1,16}];
In[]:=
Zeq=Mean[zz]
Out[]=
{9.21889,-1.85719}
In[]:=
Qeq=Mean[oo]
Out[]=
{-9.8273,0.419433}
In[]:=
ShowListPlot[{zz,oo},FrameTrue],ListPlot{{Zeq},{Qeq}},PlotStyle{Black,Black},PlotMarkers"★","★"
Out[]=
In[]:=
<<NeuralNets`
In[]:=
Plot[{Tanh[x],SaturatedLinear[x]},{x,-2,2}]
Out[]=
In[]:=
hop=HopfieldFit[{Zeq,Qeq},NetTypeContinuous,NeuronSaturatedLinear]
Out[]=
Hopfield[W,{NetTypeContinuous,WorkingPrecision4,CreationDate{2020,2,10,11,54,44.4922297},Dt0.00540352,NeuronSaturatedLinear}]
In[]:=
hop[zz[[11]]]
Out[]=
{{1.0184,-0.997897}}
In[]:=
hop[oo[[11]]]
Out[]=
{{-1.01838,1.00001}}
In[]:=
zz[[11]]
Out[]=
{10.003,0.0291984}
In[]:=
Show[NetPlot[hop,{zz[[11]]}],ImageSize->300]
Out[]=
In[]:=
NetPlot[hop,Join[zz,oo],DataFormatSurface,BoxRatios{1,0.7,0.4},PlotRangeAutomatic]
Out[]=