Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Contract a subset of vertices in a NetGraph or NetChain into a single vertex
ResourceFunction["NetContract"][net, rule1, rule2 , …] performs all the contractions specified by the rulei…. |
Define a net:
| In[1]:= | ![]() |
| Out[1]= | ![]() |
Obtain a new net by contracting everything from the starting to the ending node:
| In[2]:= |
| Out[2]= | ![]() |
Give a new name to the contracted group of vertices:
| In[3]:= |
| Out[3]= | ![]() |
Contract all the vertices after "1/a" and before "1/c":
| In[4]:= |
| Out[4]= | ![]() |
Contract all the vertices which start with the name "1/":
| In[5]:= |
| Out[5]= | ![]() |
Contract all the vertices which match a RegularExpression:
| In[6]:= |
| Out[6]= | ![]() |
Contract all the vertices which match a StringExpression:
| In[7]:= |
| Out[7]= | ![]() |
Contract all the vertices which match a pure function:
| In[8]:= |
| Out[8]= | ![]() |
Contract several sets of vertices:
| In[9]:= |
| Out[9]= | ![]() |
Simplify the net by combining ThreadingLayer and LogisticSigmoid into a single layer:
| In[10]:= | ![]() |
| Out[10]= | ![]() |
Create a new net:
| In[11]:= | ![]() |
| Out[11]= | ![]() |
Note that the new net is a bit faster:
| In[12]:= |
| In[13]:= |
| Out[13]= | ![]() |
| In[14]:= |
| Out[14]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License