MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / enable_argscope_for_module

Function enable_argscope_for_module

tensorpack/tfutils/argscope.py:122–144  ·  view source on GitHub ↗

Overwrite all functions of a given module to support argscope. Note that this function monkey-patches the module and therefore could have unexpected consequences. It has been only tested to work well with ``tf.layers`` module. Example: .. code-block:: python

(module, log_shape=True)

Source from the content-addressed store, hash-verified

120
121
122def enable_argscope_for_module(module, log_shape=True):
123 """
124 Overwrite all functions of a given module to support argscope.
125 Note that this function monkey-patches the module and therefore could
126 have unexpected consequences.
127 It has been only tested to work well with ``tf.layers`` module.
128
129 Example:
130
131 .. code-block:: python
132
133 import tensorflow as tf
134 enable_argscope_for_module(tf.layers)
135
136 Args:
137 log_shape (bool): print input/output shapes of each function.
138 """
139 if is_tfv2() and module == tf.layers:
140 module = tf.compat.v1.layers
141 for name, obj in getmembers(module):
142 if isfunction(obj):
143 setattr(module, name, enable_argscope_for_function(obj,
144 log_shape=log_shape))

Callers 4

flownet_models.pyFile · 0.90
load-vgg16.pyFile · 0.85
load-vgg19.pyFile · 0.85
mnist-tflayers.pyFile · 0.85

Calls 2

is_tfv2Function · 0.85

Tested by

no test coverage detected