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

Function rename_tflayer_get_variable

tensorpack/models/tflayer.py:92–113  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

90
91
92def 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
116def monkeypatch_tf_layers():

Callers

nothing calls this directly

Calls 1

rename_get_variableFunction · 0.85

Tested by

no test coverage detected