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
e49d4fd4
You need to sign in or sign up before continuing.
Commit
e49d4fd4
authored
Apr 10, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add notes about using sonnet (fix #222)
parent
2ba9c3cd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
6 deletions
+19
-6
README.md
README.md
+3
-2
docs/tutorial/model.md
docs/tutorial/model.md
+14
-3
examples/mnist-keras.py
examples/mnist-keras.py
+2
-1
No files found.
README.md
View file @
e49d4fd4
...
...
@@ -33,8 +33,9 @@ The examples are not only for demonstration of the framework -- you can train th
It's Yet Another TF wrapper, but different in:
1.
Not focus on models.
+
It includes only a few common models, and helpful tools such as
`LinearWrap`
to simplify large models.
But you can use any other TF wrappers here, such as slim/tflearn/tensorlayer.
+
There are already too many symbolic function wrappers.
Tensorpack includes only a few common models, and helpful tools such as
`LinearWrap`
to simplify large models.
But you can use any other wrappers within tensorpack, such as sonnet/Keras/slim/tflearn/tensorlayer/....
2.
Focus on large datasets.
+
__DataFlow__ allows you to process large datasets such as ImageNet in Python without blocking the training.
...
...
docs/tutorial/model.md
View file @
e49d4fd4
...
...
@@ -21,7 +21,7 @@ Basically, `_get_inputs` should define the metainfo of all the possible placehol
the argument
`input_tensors`
is the list of input tensors matching
`_get_inputs`
.
You can use any symbolic functions in
`_build_graph`
, including TensorFlow core library
functions
, TensorFlow slim layers, or functions in other packages such as tflean, tensorlayer
.
functions
and other symbolic libraries (see below)
.
tensorpack also contains a small collection of common model primitives,
such as conv/deconv, fc, batch normalization, pooling layers, and some custom loss functions.
...
...
@@ -62,12 +62,23 @@ l = FullyConnected('fc1', l, 10, nl=tf.identity)
### Use Models outside Tensorpack
You can use t
he t
ensorpack models alone as a simple symbolic function library, and write your own
You can use tensorpack models alone as a simple symbolic function library, and write your own
training code instead of using tensorpack trainers.
To do this, just enter a
[
TowerContext
](
http://tensorpack.readthedocs.io/en/latest/modules/tfutils.html#tensorpack.tfutils.TowerContext
)
when you define your model:
```
python
with
TowerContext
(
''
,
is_training
=
True
):
# call any tensorpack
symbolic functions
# call any tensorpack
layer
```
### Use Other Symbolic Libraries within Tensorpack
When defining the model you can construct the graph using whatever library you feel comfortable with.
Usually, slim/tflearn/tensorlayer are just symbolic functions, calling them is nothing different
from calling
`tf.add`
. However it's a bit different to use sonnet/Keras.
sonnet/Keras manages the variable scope by their own model classes, and calling their symbolic functions
always creates new variable scope. See the
[
Keras example
](
../examples/mnist-keras.py
)
for how to
use them within tensorpack.
examples/mnist-keras.py
View file @
e49d4fd4
...
...
@@ -32,7 +32,7 @@ class Model(ModelDesc):
InputDesc
(
tf
.
int32
,
(
None
,),
'label'
),
]
@
memoized
# this is necessary for Keras to work under tensorpack
@
memoized
# this is necessary for
sonnet/
Keras to work under tensorpack
def
_build_keras_model
(
self
):
M
=
Sequential
()
M
.
add
(
KL
.
Conv2D
(
32
,
3
,
activation
=
'relu'
,
input_shape
=
[
IMAGE_SIZE
,
IMAGE_SIZE
,
1
],
padding
=
'same'
))
...
...
@@ -83,6 +83,7 @@ class Model(ModelDesc):
return
tf
.
train
.
AdamOptimizer
(
lr
)
# Keras needs an extra input
class
KerasCallback
(
Callback
):
def
__init__
(
self
,
isTrain
):
self
.
_isTrain
=
isTrain
...
...
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