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)
| 1814 | |
| 1815 | |
| 1816 | def 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 | |
| 1842 | def params_with_name(name): |
no outgoing calls
no test coverage detected