Skip to content

Commit 8815760

Browse files
committed
integrated experimental infimnist data generating process as well as minor patches to noisy sin
1 parent e3b2687 commit 8815760

File tree

13 files changed

+24378
-2
lines changed

13 files changed

+24378
-2
lines changed

docs/tutorials/lesson1.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,11 +1182,14 @@ time of your graph. This would allow you to set up "events" such as when you wan
11821182
`.step()` to return updates to synapses (by setting the `calc_delta` argument to `True`
11831183
if you do and `False` otherwise) and when you want node compartments to go to
11841184
their actual resting states with a call to `.set_to_resting_state()`.
1185-
While it is flexible, we caution the user that leveraging the lower-level online
1185+
We caution the user that leveraging the lower-level online
11861186
functionality of an `NGCGraph` does require some degree of comfort with how
11871187
ngc-learn operates and care should be taken to check that your system is evolving
11881188
in the way that you expect (working with the online functionality of an NGC
1189-
system will be the subject of a future advanced lesson).
1189+
system will be the subject of a future advanced lesson). While it offers flexibility,
1190+
the `.step()` function also assumes that the experimenter will properly set
1191+
the other functions that `.settle()` normally takes care of automatically, such
1192+
as `.set_to_resting_state()`, clamping, and injecting compartment values.
11901193

11911194
### Setting the Order of Synaptic Adjustments
11921195

ngclearn/generator/experimental/__init__.py

Whitespace-only changes.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
The scripts contained in this folder, such as `infimnist_py`, have been crafted
2+
to stably work with python3 and above.
3+
4+
The Python binding for the infinite MNIST dataset generator of L. Bottou
5+
(see http://leon.bottou.org/projects/infimnist), is written in Cython.
6+
7+
**DEV NOTE:** We will be adding a real-time tensorflow generator to work with Keras
8+
and Tensorflow 2 (TF2).
9+
10+
# Installation and Integration into ngc-learn
11+
12+
In order for ngc-learn to properly recognize the data generating process
13+
under `ngclearn.generator.experimental.infimnist.infimnist`, you MUST
14+
do the following:
15+
16+
1) You need to copy (or symlink) the `data/` directory from the original infimnist
17+
project folder (available [here](http://leon.bottou.org/projects/infimnist))
18+
into the root folder of this repo.
19+
20+
The files you specifically need inside of `data/` (that you can extract from the
21+
source website's zip-file contents) are:
22+
```
23+
fields_float_1522x28x28.bin
24+
t10k-labels-idx1-ubyte
25+
train-images-idx3-ubyte
26+
t10k-images-idx3-ubyte
27+
tangVec_float_60000x28x28.bin
28+
train-labels-idx1-ubyte
29+
```
30+
31+
2) Next, build the cython extension with:
32+
33+
```
34+
$ python setup.py build_ext -if
35+
```
36+
37+
3) Finally, go up/back to the main ngc-learn directory `/ngc-learn/` and re-run
38+
the primary library building script:
39+
40+
```
41+
$ python setup.py install
42+
```
43+
44+
and the InfiMNIST package should be successfully integrated into the ngc-learn
45+
primary library package. If you do not complete the above directions, ngc-learn
46+
will throw an error as it will not properly recognize the InfiMNIST sampler
47+
in the `generator.experimental` module sub-directory.
48+
49+
# Example Usage
50+
The following code gives the first test example (0), the first training example
51+
(10000) and its first transformation (70000). The indexing logic follows that
52+
of the original infimnist binary described [here](http://leon.bottou.org/projects/infimnist).
53+
ngc-learn has built internally a wrapper "generator" to convert the original
54+
infinite mnist into an on-the-fly (mini-batch) sampler/stochastic data generating
55+
process.
56+
57+
```python
58+
from ngclearn.generator.experimental.infimnist.infimnist import InfiMNIST
59+
import matplotlib.pyplot as plt
60+
61+
n_iter = 10 # bound your computation by a maximum number of iterations to simulate
62+
63+
sampler = InfiMNIST(batch_size=8)
64+
65+
for t in range(n_iter):
66+
x, y = sampler.sample()
67+
68+
# Update NGC agent given x, y
69+
# WRITEME: agent code goes here...
70+
71+
# You can also plot images using matplotlib and save to disk if you like
72+
import matplotlib.pyplot as plt
73+
plt.imshow(x[0].reshape(28,28))
74+
plt.title('label: {}'.format(y[0]))
75+
plt.savefig("sample{}.jpg".format(t))
76+
```
77+
78+
**DEV NOTE:** Future versions of InfiMNIST will offer support for tf.records.

ngclearn/generator/experimental/infimnist/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)