This tutorial covers how data goes from DataFlow or other sources to TensorFlow graph.
This tutorial covers how data goes from DataFlow or other sources to TensorFlow graph.
You don't have to know it, but it may help with efficiency.
You don't have to read it because these are details under the tensorpack interface, but knowing it could help understand the efficiency.
`InputSource` is an abstract interface in tensorpack describing where the input come from and how they enter the graph.
`InputSource` is an abstract interface in tensorpack describing where the input come from and how they enter the graph.
For example,
For example,
...
@@ -18,7 +18,7 @@ to customize your `InputSource`.
...
@@ -18,7 +18,7 @@ to customize your `InputSource`.
## Use Prefetch
## Use Prefetch
In general, `feed_dict` is slow and should never appear in your critical loop.
In general, `feed_dict` is slow and should never appear in training loops.
i.e., when you use TensorFlow without any wrappers, you should avoid loops like this:
i.e., when you use TensorFlow without any wrappers, you should avoid loops like this:
```python
```python
whileTrue:
whileTrue:
...
@@ -26,9 +26,9 @@ while True:
...
@@ -26,9 +26,9 @@ while True:
minimize_op.run(feed_dict={'X':X,'y':y})
minimize_op.run(feed_dict={'X':X,'y':y})
```
```
However, when you need to load data from Python-side, this is the only available interface in frameworks such as Keras, tflearn.
However, when you need to load data from Python-side, this is the only available interface in frameworks such as Keras, tflearn.
This is part of the reason why [tensorpack is faster](https://gist.github.com/ppwwyyxx/8d95da79f8d97036a7d67c2416c851b6) than examples from other frameworks.
This is part of the reason why [tensorpack is faster](https://gist.github.com/ppwwyyxx/8d95da79f8d97036a7d67c2416c851b6).
You should use something like this instead, to prefetch data into the graph in one thread and hide the copy latency:
You could use something like this instead, to prefetch data into the graph in one thread and hide the copy latency: