WOLFRAM NOTEBOOK

In[]:=
RRnet[{3,3}]
Out[]=
NetChain
Inputport:
real
Outputport:
real
In[]:=
NetInitialize[%]
Out[]=
NetChain
Inputport:
real
Outputport:
real
In[]:=
inet=%69;
In[]:=
NetGraphPlot[%]
Out[]=
In[]:=
Plot[inet[x],{x,-3,3}]
Out[]=
In[]:=
Information[inet,"Arrays"]
Out[]=
{1,Biases}NumericArray
Type: Real32
Dimensions: {3}
,{1,Weights}NumericArray
Type: Real32
Dimensions: {3,1}
,{3,Biases}NumericArray
Type: Real32
Dimensions: {3}
,{3,Weights}NumericArray
Type: Real32
Dimensions: {3,3}
,{5,Biases}NumericArray
Type: Real32
Dimensions: {1}
,{5,Weights}NumericArray
Type: Real32
Dimensions: {1,3}
In[]:=
Clear[PerturbNet]
In[]:=
PerturbNet[net_,{opos_,ipos_},delta_]:=Module[{assoc=Information[net,"Arrays"]},NetReplacePart[net,opos->NumericArray[With[{rhs=Normal[Information[net,"Arrays"][opos]]},ReplacePart[rhs,ipos->(Extract[rhs,ipos]+delta)]],"Real32"]]]
In[]:=
PerturbNet[inet,{{3,"Weights"},{1,3}},4.]
Out[]=
NetChain
Inputport:
real
Outputport:
real
In[]:=
NetGraphPlot[%]
Out[]=
In[]:=
rinet=NetInitialize[RRnetELU[{3,3}],RandomSeeding->2132134]
Out[]=
NetChain
Inputport:
real
Outputport:
real
In[]:=
NetParams[net_,patt_:{_,"Weights"}]:=Catenate[Function[u,{First[u],#}&/@Last[u]]/@KeyValueMap[#1->Flatten[Array[List,Dimensions[#2]],TensorRank[Normal@#2]-1]&,KeySelect[Information[net,"Arrays"],MatchQ[patt]]]]
In[]:=
NetParams[rinet]
Out[]=
{{{1,Weights},{1,1}},{{1,Weights},{2,1}},{{1,Weights},{3,1}},{{3,Weights},{1,1}},{{3,Weights},{1,2}},{{3,Weights},{1,3}},{{3,Weights},{2,1}},{{3,Weights},{2,2}},{{3,Weights},{2,3}},{{3,Weights},{3,1}},{{3,Weights},{3,2}},{{3,Weights},{3,3}},{{5,Weights},{1,1}},{{5,Weights},{1,2}},{{5,Weights},{1,3}}}
In[]:=
GraphicsGrid[Partition[NetGraphPlot[PerturbNet[rinet,#,8]]&/@NetParams[rinet],5]]
Out[]=
In[]:=
GraphicsGrid[Partition[With[{p=PerturbNet[rinet,#,8]},Plot[p[x],{x,-3,3},PlotTheme->"Minimal"]]&/@NetParams[rinet],5]]
Out[]=
In[]:=
GraphicsGrid[Partition[With[{p=PerturbNet[rinet,#,.1]},Plot[p[x],{x,-3,3},PlotTheme->"Minimal"]]&/@NetParams[rinet],5]]
Out[]=
In[]:=
GraphicsGrid[Partition[With[{p=PerturbNet[rinet,#,.5]},Plot[p[x],{x,-3,3},PlotTheme->"Minimal"]]&/@NetParams[rinet],5]]
Out[]=
Wolfram Cloud

You are using a browser not supported by the Wolfram Cloud

Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


I understand and wish to continue anyway »

You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.