Skip to content
This repository was archived by the owner on Dec 13, 2022. It is now read-only.

Commit c36d9ba

Browse files
committed
Added the missing example from usage.md
1 parent 6bed1c9 commit c36d9ba

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/docs_md/usage.md

+26
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,30 @@ p.remove_macro(node_hash) # Will delete the macro the node belongs to.
173173
Loads the mnist dataset from a numpy array + the labels associated.
174174
It then reshape the images to be actual `(28, 28)`, resize them to another resolution
175175
and creates batches from them.
176+
```python
177+
# Create pipeline
178+
p = Pipeline()
176179

180+
# Create nodes
181+
load_images = p.add_node('np_iter_file', path='tests/data/mnist.npy')
182+
load_labels = p.add_node('np_iter_file', path='tests/data/mnist_labels.npy')
183+
reshape = p.add_node('np_reshape', shape=(28, 28))
184+
resize = p.add_node('resize_cv2', width=56, height=56)
185+
batch_images = p.add_node('batchify/images', size=32)
186+
batch_labels = p.add_node('batchify/labels', size=32)
187+
188+
# Add connections
189+
p.add_conn(load_images, 0, reshape, 0)
190+
p.add_conn(reshape, 0, resize, 0)
191+
p.add_conn(resize, 0, batch_images, 0)
192+
p.add_conn(load_labels, 0, batch_labels, 0)
193+
194+
# Set outputs
195+
p.add_output(batch_images)
196+
p.add_output(batch_labels)
197+
198+
# Run it
199+
p.run(slow=False, use_mp=False)
200+
for batch_x, batch_y in zip(p.outputs['images'], p.outputs['labels']):
201+
print(batch_x.shape, batch_y.shape)
202+
```

0 commit comments

Comments
 (0)