Skip to content

Commit 9edffc3

Browse files
neerajpradfritzo
authored andcommitted
Scrub output and metadata of ipynb files for git commits (pyro-ppl#400)
1 parent b71d91f commit 9edffc3

File tree

9 files changed

+66
-176
lines changed

9 files changed

+66
-176
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.ipynb filter=nbstripout
2+
*.ipynb diff=ipynb

.gitconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[filter "nbstripout"]
2+
clean = "python -m nbstripout"
3+
smudge = cat
4+
required = true
5+
[diff "ipynb"]
6+
textconv = nbstripout -t

CONTRIBUTING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
# Development
22
For consistency, please adhere to the established coding style including variable names, module imports, and function definitions. The Pyro codebase uses the PEP8 style guide.
33

4+
# Setup
5+
6+
Install all the dev dependencies for Pyro.
7+
8+
```sh
9+
pip install -e .[dev]
10+
```
11+
12+
Add the repository's git configuration to your local project `.gitconfig` file.
13+
14+
```sh
15+
git config --local include.path ../.gitconfig
16+
```
17+
418
# Testing
519

620
Before submitting a pull request, please ensure that linting and unit tests pass locally

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
'pytest-xdist',
3131
'nbval',
3232
'yapf',
33+
'nbstripout',
3334
'sphinx',
3435
'sphinx_rtd_theme',
3536
],

tutorial/bayesian_regression.ipynb

Lines changed: 18 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
},
2424
{
2525
"cell_type": "code",
26-
"execution_count": 19,
27-
"metadata": {
28-
"collapsed": true
29-
},
26+
"execution_count": null,
27+
"metadata": {},
3028
"outputs": [],
3129
"source": [
3230
"import numpy as np\n",
@@ -51,10 +49,8 @@
5149
},
5250
{
5351
"cell_type": "code",
54-
"execution_count": 20,
55-
"metadata": {
56-
"collapsed": true
57-
},
52+
"execution_count": null,
53+
"metadata": {},
5854
"outputs": [],
5955
"source": [
6056
"N = 100 # size of toy data\n",
@@ -78,10 +74,8 @@
7874
},
7975
{
8076
"cell_type": "code",
81-
"execution_count": 21,
82-
"metadata": {
83-
"collapsed": true
84-
},
77+
"execution_count": null,
78+
"metadata": {},
8579
"outputs": [],
8680
"source": [
8781
"class RegressionModel(nn.Module):\n",
@@ -105,33 +99,9 @@
10599
},
106100
{
107101
"cell_type": "code",
108-
"execution_count": 23,
102+
"execution_count": null,
109103
"metadata": {},
110-
"outputs": [
111-
{
112-
"name": "stdout",
113-
"output_type": "stream",
114-
"text": [
115-
"105.713066101\n",
116-
"102.354705811\n",
117-
"102.354682922\n",
118-
"102.354660034\n",
119-
"102.354660034\n",
120-
"102.354660034\n",
121-
"102.354660034\n",
122-
"102.354660034\n",
123-
"102.354660034\n",
124-
"102.354660034\n",
125-
"Parameters: [('linear.weight', Parameter containing:\n",
126-
" 2.9949\n",
127-
"[torch.FloatTensor of size 1x1]\n",
128-
"), ('linear.bias', Parameter containing:\n",
129-
" 1.0565\n",
130-
"[torch.FloatTensor of size 1]\n",
131-
")]\n"
132-
]
133-
}
134-
],
104+
"outputs": [],
135105
"source": [
136106
"loss_fn = torch.nn.MSELoss(size_average=False)\n",
137107
"optim = torch.optim.Adam(regression_model.parameters(), lr=0.01)\n",
@@ -175,10 +145,8 @@
175145
},
176146
{
177147
"cell_type": "code",
178-
"execution_count": 24,
179-
"metadata": {
180-
"collapsed": true
181-
},
148+
"execution_count": null,
149+
"metadata": {},
182150
"outputs": [],
183151
"source": [
184152
"mu = Variable(torch.zeros(1, 1))\n",
@@ -203,10 +171,8 @@
203171
},
204172
{
205173
"cell_type": "code",
206-
"execution_count": 25,
207-
"metadata": {
208-
"collapsed": true
209-
},
174+
"execution_count": null,
175+
"metadata": {},
210176
"outputs": [],
211177
"source": [
212178
"def model(data):\n",
@@ -256,26 +222,9 @@
256222
},
257223
{
258224
"cell_type": "code",
259-
"execution_count": 26,
225+
"execution_count": null,
260226
"metadata": {},
261-
"outputs": [
262-
{
263-
"name": "stdout",
264-
"output_type": "stream",
265-
"text": [
266-
"epoch avg loss 1.53375732422\n",
267-
"epoch avg loss 1.55264312744\n",
268-
"epoch avg loss 1.54637115479\n",
269-
"epoch avg loss 1.56145004272\n",
270-
"epoch avg loss 1.55594955444\n",
271-
"epoch avg loss 1.55865844727\n",
272-
"epoch avg loss 1.55234939575\n",
273-
"epoch avg loss 1.55432601929\n",
274-
"epoch avg loss 1.55954589844\n",
275-
"epoch avg loss 1.55867294312\n"
276-
]
277-
}
278-
],
227+
"outputs": [],
279228
"source": [
280229
"optim = Adam({\"lr\": 0.01})\n",
281230
"svi = SVI(model, guide, optim, loss=\"ELBO\")\n",
@@ -303,29 +252,9 @@
303252
},
304253
{
305254
"cell_type": "code",
306-
"execution_count": 27,
255+
"execution_count": null,
307256
"metadata": {},
308-
"outputs": [
309-
{
310-
"name": "stdout",
311-
"output_type": "stream",
312-
"text": [
313-
"{'guide_log_sigma_bias': Variable containing:\n",
314-
"-2.2687\n",
315-
"[torch.FloatTensor of size 1]\n",
316-
", 'guide_log_sigma_weight': Variable containing:\n",
317-
"-3.5816\n",
318-
"[torch.FloatTensor of size 1x1]\n",
319-
", 'guide_mean_weight': Variable containing:\n",
320-
" 2.9820\n",
321-
"[torch.FloatTensor of size 1x1]\n",
322-
", 'guide_mean_bias': Variable containing:\n",
323-
" 1.2036\n",
324-
"[torch.FloatTensor of size 1]\n",
325-
"}\n"
326-
]
327-
}
328-
],
257+
"outputs": [],
329258
"source": [
330259
"print pyro.get_param_store()._params"
331260
]
@@ -346,21 +275,9 @@
346275
},
347276
{
348277
"cell_type": "code",
349-
"execution_count": 28,
278+
"execution_count": null,
350279
"metadata": {},
351-
"outputs": [
352-
{
353-
"name": "stdout",
354-
"output_type": "stream",
355-
"text": [
356-
"Variable containing:\n",
357-
"1.00000e-04 *\n",
358-
" 5.8031\n",
359-
"[torch.FloatTensor of size 1]\n",
360-
"\n"
361-
]
362-
}
363-
],
280+
"outputs": [],
364281
"source": [
365282
"X = np.linspace(8, 12, num=20)\n",
366283
"y = 3 * X + 1\n",

0 commit comments

Comments
 (0)