Commit 871025d6 authored by Yuxin Wu's avatar Yuxin Wu

argscope tutorial with more argscope(fix #1147)

parent 520a12d7
......@@ -37,6 +37,9 @@ with argscope(Conv2D, filters=32, kernel_size=3, activation=tf.nn.relu):
.tf.multiply(0.5)
.apply(func, *args, **kwargs)
.FullyConnected('fc1', units=10, activation=tf.identity)())
with argscope([Conv2D, MaxPooling], data_format='NCHW'), argscope(Conv2D, kernel_size=1):
l2 = LinearWrap(image).Conv2D('conv3', strides=2).MaxPooling('pool3', 2)
```
is equivalent to:
```
......@@ -49,6 +52,9 @@ l = Dropout('dropout', l, rate=0.5)
l = tf.multiply(l, 0.5)
l = func(l, *args, **kwargs)
l = FullyConnected('fc1', l, 10, activation=tf.identity)
l2 = Conv2D('conv3', image, 32, 1, strides=2, data_format='NCHW', activation=tf.nn.relu)
l2 = MaxPooling('pool3', l2, 2, data_format='NCHW')
```
If you need to access the output of some layer and use it with some other
......
......@@ -92,6 +92,10 @@ class ReuseSessionCreator(tf.train.SessionCreator):
class SessionCreatorAdapter(tf.train.SessionCreator):
"""
Apply a function on the output of a SessionCreator. Can be used to create a debug session.
Note:
Since TF 1.6, debug session may not work properly with Monitored session.
This is a tensorflow bug. To use tfdbg, use the :class:`TFLocalCLIDebugHook` callback instead.
"""
def __init__(self, session_creator, func):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment