Skip to content

Commit 8a01009

Browse files
committed
Merge branch 'dev'
# Conflicts: # pynever/config/configuration.ini # pyproject.toml
2 parents 53b5a4e + 5c1dcd5 commit 8a01009

24 files changed

Lines changed: 683 additions & 198 deletions

.github/workflows/deploy-docs.yml

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,42 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- name: Checkout code
14-
uses: actions/checkout@v3
15-
16-
- name: Set up Python
17-
uses: actions/setup-python@v4
18-
with:
19-
python-version: '3.11'
20-
21-
- name: Install dependencies
22-
run: |
23-
python -m pip install --upgrade pip
24-
pip install .
25-
pip install sphinx sphinx-autodoc-typehints sphinx-rtd-theme
26-
27-
- name: Build Sphinx documentation
28-
run: |
29-
cd docs
30-
sphinx-build -M html . _build/
31-
32-
- name: Clone GitHub Pages repo
33-
run: |
34-
git config --global user.name "github-actions"
35-
git config --global user.email "github-actions@github.com"
36-
git clone https://x-access-token:${{ secrets.GH_PAGES_DEPLOY }}@github.com/nevertools/nevertools.github.io.git gh-pages
37-
env:
38-
GH_PAGES_DEPLOY_TOKEN: ${{ secrets.GH_PAGES_DEPLOY }}
39-
40-
- name: Copy docs to gh-pages/pynever
41-
run: |
42-
rm -rf gh-pages/pynever
43-
mkdir -p gh-pages/pynever
44-
cp -r docs/_build/html/* gh-pages/pynever/
45-
46-
- name: Commit and push changes
47-
run: |
48-
cd gh-pages
49-
git add pynever
50-
git commit -m "Update API docs from pynever" || echo "No changes to commit"
51-
git push origin master
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.11'
20+
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install .
25+
pip install -r docs/requirements.txt
26+
27+
- name: Build Sphinx documentation
28+
run: |
29+
cd docs
30+
sphinx-build -M html . _build/
31+
32+
- name: Clone GitHub Pages repo
33+
run: |
34+
git config --global user.name "github-actions"
35+
git config --global user.email "github-actions@github.com"
36+
git clone https://x-access-token:${{ secrets.GH_PAGES_DEPLOY }}@github.com/nevertools/nevertools.github.io.git gh-pages
37+
env:
38+
GH_PAGES_DEPLOY_TOKEN: ${{ secrets.GH_PAGES_DEPLOY }}
39+
40+
- name: Copy docs to gh-pages/pynever
41+
run: |
42+
rm -rf gh-pages/pynever
43+
mkdir -p gh-pages/pynever
44+
cp -r docs/_build/html/* gh-pages/pynever/
45+
46+
- name: Commit and push changes
47+
run: |
48+
cd gh-pages
49+
git add pynever
50+
git commit -m "Update API docs from pynever" || echo "No changes to commit"
51+
git push origin master

docs/Guide/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Verification
1+
Stand-alone
22
============
33

44
Command-line interface

docs/conf.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,20 @@
3434
'sphinx.ext.autodoc',
3535
'sphinx.ext.napoleon',
3636
'sphinx_autodoc_typehints',
37-
'sphinx.ext.linkcode',
37+
'sphinx.ext.linkcode'
3838
]
3939

4040
autodoc_member_order = 'bysource'
41+
# nbsphinx_execute = 'never'
42+
# nbsphinx_allow_errors = True
4143

4244
# Add any paths that contain templates here, relative to this directory.
4345
# templates_path = ['_templates']
4446

4547
# List of patterns, relative to source directory, that match files and
4648
# directories to ignore when looking for source files.
4749
# This pattern also affects html_static_path and html_extra_path.
48-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'README*']
50+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'README*', '**.ipynb_checkpoints']
4951

5052
# -- Options for HTML output -------------------------------------------------
5153

docs/requirements.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Packages in addition to test_requirements.txt
2+
# needed to build python documentation
3+
Sphinx
4+
sphinx-rtd-theme
5+
sphinx-autodoc-typehints
6+
Pygments
7+
nbsphinx

examples/notebooks/00 - Introduction.ipynb

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
{
2+
"cells": [
3+
{
4+
"metadata": {},
5+
"cell_type": "markdown",
6+
"source": [
7+
"# API - Networks\n",
8+
"\n",
9+
"This notebook illustrates the main features of pyNeVer for the creation of a neural network"
10+
],
11+
"id": "7386e4bcb1b4c027"
12+
},
13+
{
14+
"metadata": {},
15+
"cell_type": "markdown",
16+
"source": [
17+
"## The _networks_ module\n",
18+
"\n",
19+
"The module *networks* contains the classes __SequentialNetwork__ and __AcyclicNetwork__ to represent feed-forward and residual neural networks, respectively. Both subclass the abstract class __NeuralNetwork__ that provides base methods and utilities."
20+
],
21+
"id": "180d25f1124192a2"
22+
},
23+
{
24+
"metadata": {},
25+
"cell_type": "code",
26+
"source": [
27+
"from pynever.networks import NeuralNetwork, SequentialNetwork, AcyclicNetwork\n",
28+
"\n",
29+
"# Create an empty FF network with identifier 'my_net' and input identifier 'X'\n",
30+
"my_ff_net = SequentialNetwork('my_awesome_ff_net', 'X')\n",
31+
"\n",
32+
"# Create an empty ResNet. Notice that the input identifiers are in a list to allow multiple inputs.\n",
33+
"my_res_net = AcyclicNetwork('my_awesome_res_net', ['X_b', 'X_b'])\n",
34+
"\n",
35+
"print(my_ff_net)\n",
36+
"print(my_res_net)\n",
37+
"\n",
38+
"print(isinstance(my_ff_net, NeuralNetwork))\n",
39+
"print(isinstance(my_res_net, NeuralNetwork))"
40+
],
41+
"id": "b63800010ce3b95a",
42+
"outputs": [],
43+
"execution_count": null
44+
},
45+
{
46+
"metadata": {},
47+
"cell_type": "markdown",
48+
"source": [
49+
"## The _nodes_ module\n",
50+
"\n",
51+
"The module *nodes* contains the definition of NN layers as nodes in the computational graph. For the list of all supported layers, see [the documentation](http://www.neuralverification.org/pynever/API/1_Nodes.html). All nodes require a string identifier and the definition of the input dimension: the neural network object contains no information about this."
52+
],
53+
"id": "2c88535153a53d36"
54+
},
55+
{
56+
"metadata": {},
57+
"cell_type": "code",
58+
"source": [
59+
"from pynever import nodes\n",
60+
"import torch\n",
61+
"\n",
62+
"w = torch.Tensor([[1, 1], [-1, 1]])\n",
63+
"b = torch.zeros(2)\n",
64+
"\n",
65+
"# Create a fully connected layer with 2 inputs and 2 neurons.\n",
66+
"# The input dimension in_dim is always a tuple\n",
67+
"fc = nodes.FullyConnectedNode('fc', (2,), 2, weight=w, bias=b)\n",
68+
"\n",
69+
"# Add it to the ff network\n",
70+
"my_ff_net.append_node(fc)\n",
71+
"# Let's add a ReLU layer now\n",
72+
"my_ff_net.append_node(nodes.ReLUNode('relu', (2,)))\n",
73+
"\n",
74+
"print(my_ff_net)"
75+
],
76+
"id": "2667008980c520b5",
77+
"outputs": [],
78+
"execution_count": null
79+
},
80+
{
81+
"metadata": {},
82+
"cell_type": "markdown",
83+
"source": [
84+
"## Residual networks\n",
85+
"\n",
86+
"For ResNets we provide a different method to add layers: *add_node* allows to specify the layer parents and, possibly, children"
87+
],
88+
"id": "a8b5ddea7d01fad7"
89+
},
90+
{
91+
"metadata": {},
92+
"cell_type": "code",
93+
"source": [
94+
"rl = nodes.ReLUNode('relu', (2,))\n",
95+
"fc_2 = nodes.FullyConnectedNode('fc_2', (2,), 2, weight=w, bias=b)\n",
96+
"rl_2 = nodes.ReLUNode('relu_2', (2,))\n",
97+
"\n",
98+
"my_res_net.add_node(fc) # This is the first layer\n",
99+
"my_res_net.add_node(rl, [fc]) # Layer rl follows fc\n",
100+
"my_res_net.add_node(fc_2, [rl]) # Layer fc_2 follows rl\n",
101+
"my_res_net.add_node(rl_2, [fc, fc_2]) # Layer rl_2 has a skip connection and has as parents both fc and fc_2\n",
102+
"\n",
103+
"print(my_res_net)\n",
104+
"\n",
105+
"# A few utility methods\n",
106+
"print(f'Topological sort: {my_res_net.get_topological_order()}')\n",
107+
"print(f'Parents of rl_2: {my_res_net.get_parents(rl_2)}')\n",
108+
"print(f'Children of fc: {my_res_net.get_children(fc)}')\n",
109+
"print(f'Leaves of the nn: {my_res_net.get_leaves()}')"
110+
],
111+
"id": "fedaca77cdea61f",
112+
"outputs": [],
113+
"execution_count": null
114+
},
115+
{
116+
"metadata": {},
117+
"cell_type": "markdown",
118+
"source": "",
119+
"id": "bada530cf2b5aa93"
120+
}
121+
],
122+
"metadata": {
123+
"kernelspec": {
124+
"display_name": "Python 3",
125+
"language": "python",
126+
"name": "python3"
127+
},
128+
"language_info": {
129+
"codemirror_mode": {
130+
"name": "ipython",
131+
"version": 2
132+
},
133+
"file_extension": ".py",
134+
"mimetype": "text/x-python",
135+
"name": "python",
136+
"nbconvert_exporter": "python",
137+
"pygments_lexer": "ipython2",
138+
"version": "2.7.6"
139+
}
140+
},
141+
"nbformat": 4,
142+
"nbformat_minor": 5
143+
}

0 commit comments

Comments
 (0)