MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / param

Function param

numpy_ml/tests/nn_torch_models.py:1816–1839  ·  view source on GitHub ↗

A wrapper for `tf.Variable` which enables parameter sharing in models. Creates and returns theano shared variables similarly to `tf.Variable`, except if you try to create a param with the same name as a previously-created one, `param(...)` will just return the old one instead of

(name, *args, **kwargs)

Source from the content-addressed store, hash-verified

1814
1815
1816def param(name, *args, **kwargs):
1817 """
1818 A wrapper for `tf.Variable` which enables parameter sharing in models.
1819
1820 Creates and returns theano shared variables similarly to `tf.Variable`,
1821 except if you try to create a param with the same name as a
1822 previously-created one, `param(...)` will just return the old one instead of
1823 making a new one.
1824
1825 This constructor also adds a `param` attribute to the shared variables it
1826 creates, so that you can easily search a graph for all params.
1827 """
1828
1829 if name not in _params:
1830 kwargs["name"] = name
1831 param = tf.Variable(*args, **kwargs)
1832 param.param = True
1833 _params[name] = param
1834 result = _params[name]
1835 i = 0
1836 while result in _param_aliases:
1837 i += 1
1838 result = _param_aliases[result]
1839 return result
1840
1841
1842def params_with_name(name):

Callers 2

ReLULayerFunction · 0.85
LinearLayerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected