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)
| 120 | |
| 121 | |
| 122 | def 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)) |
no test coverage detected