Rename all :func:`tf.get_variable` with rules that transforms tflayer style to tensorpack style. Returns: A context where the variables are renamed. Example: .. code-block:: python with rename_tflayer_get_variable(): x = tf.layer.conv2d(input, 3, 3, n
()
| 90 | |
| 91 | |
| 92 | def rename_tflayer_get_variable(): |
| 93 | """ |
| 94 | Rename all :func:`tf.get_variable` with rules that transforms tflayer style to tensorpack style. |
| 95 | |
| 96 | Returns: |
| 97 | A context where the variables are renamed. |
| 98 | |
| 99 | Example: |
| 100 | |
| 101 | .. code-block:: python |
| 102 | |
| 103 | with rename_tflayer_get_variable(): |
| 104 | x = tf.layer.conv2d(input, 3, 3, name='conv0') |
| 105 | # variables will be named 'conv0/W', 'conv0/b' |
| 106 | """ |
| 107 | mapping = { |
| 108 | 'kernel': 'W', |
| 109 | 'bias': 'b', |
| 110 | 'moving_mean': 'mean/EMA', |
| 111 | 'moving_variance': 'variance/EMA', |
| 112 | } |
| 113 | return rename_get_variable(mapping) |
| 114 | |
| 115 | |
| 116 | def monkeypatch_tf_layers(): |
nothing calls this directly
no test coverage detected