Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
62332e0f
You need to sign in or sign up before continuing.
Commit
62332e0f
authored
Jun 21, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update readme
parent
76e216eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
18 deletions
+15
-18
README.md
README.md
+1
-0
examples/DoReFa-Net/README.md
examples/DoReFa-Net/README.md
+12
-8
examples/DoReFa-Net/alexnet.py
examples/DoReFa-Net/alexnet.py
+2
-10
No files found.
README.md
View file @
62332e0f
...
@@ -5,6 +5,7 @@ In development but usable. API might change a bit.
...
@@ -5,6 +5,7 @@ In development but usable. API might change a bit.
See some interesting
[
examples
](
https://github.com/ppwwyyxx/tensorpack/tree/master/examples
)
to learn about the framework:
See some interesting
[
examples
](
https://github.com/ppwwyyxx/tensorpack/tree/master/examples
)
to learn about the framework:
+
[
DoReFa-Net: low bitwidth CNN
](
https://github.com/ppwwyyxx/tensorpack/tree/master/examples/DoReFa-Net
)
+
[
Double-DQN for playing Atari games
](
https://github.com/ppwwyyxx/tensorpack/tree/master/examples/Atari2600
)
+
[
Double-DQN for playing Atari games
](
https://github.com/ppwwyyxx/tensorpack/tree/master/examples/Atari2600
)
+
[
ResNet for Cifar10 classification
](
https://github.com/ppwwyyxx/tensorpack/tree/master/examples/ResNet
)
+
[
ResNet for Cifar10 classification
](
https://github.com/ppwwyyxx/tensorpack/tree/master/examples/ResNet
)
+
[
char-rnn language model
](
https://github.com/ppwwyyxx/tensorpack/tree/master/examples/char-rnn
)
+
[
char-rnn language model
](
https://github.com/ppwwyyxx/tensorpack/tree/master/examples/char-rnn
)
...
...
examples/DoReFa-Net/README.md
View file @
62332e0f
...
@@ -2,9 +2,7 @@ This is the official script to load and run pretrained model for the paper:
...
@@ -2,9 +2,7 @@ This is the official script to load and run pretrained model for the paper:
[
DoReFa-Net: Training Low Bitwidth Convolutional Neural Networks with Low Bitwidth Gradients
](
http://arxiv.org/abs/1606.06160
)
, by Zhou et al.
[
DoReFa-Net: Training Low Bitwidth Convolutional Neural Networks with Low Bitwidth Gradients
](
http://arxiv.org/abs/1606.06160
)
, by Zhou et al.
(Work in Progress. More instructions to come soon)
The provided model is an AlexNet with 1 bit weights, 2 bit activations, trained with 4 bit gradients.
This is an AlexNet model with 1 bit weights, 2 bit activations, trained with 4 bit gradients.
## Preparation:
## Preparation:
...
@@ -12,25 +10,26 @@ To use the script. You'll need:
...
@@ -12,25 +10,26 @@ To use the script. You'll need:
+
[
TensorFlow
](
tensorflow.org
)
>= 0.8
+
[
TensorFlow
](
tensorflow.org
)
>= 0.8
+
[
tensorpack
](
https://github.com/ppwwyyxx/tensorpack
)
and pyzmq
:
+
[
tensorpack
](
https://github.com/ppwwyyxx/tensorpack
)
:
```
```
git clone https://github.com/ppwwyyxx/tensorpack
git clone https://github.com/ppwwyyxx/tensorpack
pip install --user -r tensorpack/requirements.txt
pip install --user -r tensorpack/requirements.txt
pip install --user pyzmq
export PYTHONPATH=$PYTHONPATH:`readlink -f tensorpack`
export PYTHONPATH=$PYTHONPATH:`readlink -f tensorpack`
```
```
+
Download the model at
[
google drive
](
https://drive.google.com/drive/u/2/folders/0B308TeQzmFDLa0xOeVQwcXg1ZjQ
)
## Load and run the model
## Load and run the model
We p
rovide two format for the model
:
We p
ublish the model in two file formats
:
1.
alexnet.npy. It's simply a numpy dict of {param name: value}. To load
:
1.
`alexnet.npy`
. It's simply a numpy dict of {param name: value}. Use it with
:
```
```
./alexnet.py --load alexnet.npy [--input img.jpg] [--data path/to/data]
./alexnet.py --load alexnet.npy [--input img.jpg] [--data path/to/data]
```
```
2.
alexnet.meta + alexnet.tfmodel
. A TensorFlow MetaGraph proto and a saved checkpoint.
2.
`alexnet.meta`
+
`alexnet.tfmodel`
. A TensorFlow MetaGraph proto and a saved checkpoint.
```
```
./alexnet.py --graph alexnet.meta --load alexnet.tfmodel [--input path/to/img.jpg] [--data path/to/ILSVRC12]
./alexnet.py --graph alexnet.meta --load alexnet.tfmodel [--input path/to/img.jpg] [--data path/to/ILSVRC12]
...
@@ -38,3 +37,8 @@ We provide two format for the model:
...
@@ -38,3 +37,8 @@ We provide two format for the model:
One of
`--data`
or
`--input`
must be present, to either run classification on some input images, or run evaluation on ILSVRC12 validation set.
One of
`--data`
or
`--input`
must be present, to either run classification on some input images, or run evaluation on ILSVRC12 validation set.
To eval on ILSVRC12,
`path/to/ILSVRC12`
must have a subdirectory named 'val' containing all the validation images.
To eval on ILSVRC12,
`path/to/ILSVRC12`
must have a subdirectory named 'val' containing all the validation images.
## Support
Please use
[
github issues
](
https://github.com/ppwwyyxx/tensorpack/issues
)
for any issues related to the code.
Send email to the authors for other questions related to the paper.
examples/DoReFa-Net/alexnet.py
View file @
62332e0f
...
@@ -8,15 +8,6 @@ import argparse
...
@@ -8,15 +8,6 @@ import argparse
import
numpy
as
np
import
numpy
as
np
import
os
import
os
"""
Run the pretrained model of paper:
DoReFa-Net: Training Low Bitwidth Convolutional Neural Networks with Low Bitwidth Gradients
http://arxiv.org/abs/1606.06160
Model can be downloaded at:
https://drive.google.com/drive/u/2/folders/0B308TeQzmFDLa0xOeVQwcXg1ZjQ
"""
from
tensorpack
import
*
from
tensorpack
import
*
from
tensorpack.utils.stat
import
RatioCounter
from
tensorpack.utils.stat
import
RatioCounter
from
tensorpack.tfutils.symbolic_functions
import
prediction_incorrect
from
tensorpack.tfutils.symbolic_functions
import
prediction_incorrect
...
@@ -76,7 +67,7 @@ def eval_on_ILSVRC12(model, sess_init, data_dir):
...
@@ -76,7 +67,7 @@ def eval_on_ILSVRC12(model, sess_init, data_dir):
]
]
ds
=
AugmentImageComponent
(
ds
,
transformers
)
ds
=
AugmentImageComponent
(
ds
,
transformers
)
ds
=
BatchData
(
ds
,
128
,
remainder
=
True
)
ds
=
BatchData
(
ds
,
128
,
remainder
=
True
)
ds
=
PrefetchData
ZMQ
(
ds
,
10
)
# TODO use PrefetchData as fallback
ds
=
PrefetchData
(
ds
,
10
,
nr_proc
=
1
)
cfg
=
PredictConfig
(
cfg
=
PredictConfig
(
model
=
model
,
model
=
model
,
...
@@ -155,6 +146,7 @@ op/variable names")
...
@@ -155,6 +146,7 @@ op/variable names")
raise
RuntimeError
(
"Unsupported model type!"
)
raise
RuntimeError
(
"Unsupported model type!"
)
if
args
.
data
:
if
args
.
data
:
assert
os
.
path
.
isdir
(
os
.
path
.
join
(
args
.
data
,
'val'
))
eval_on_ILSVRC12
(
M
,
sess_init
,
args
.
data
)
eval_on_ILSVRC12
(
M
,
sess_init
,
args
.
data
)
elif
args
.
input
:
elif
args
.
input
:
run_test
(
M
,
sess_init
,
args
.
input
)
run_test
(
M
,
sess_init
,
args
.
input
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment