def shared_like(variable, name=None):
"""Construct a shared variable to hold the value of a tensor variable.
Parameters
----------
variable : :class:`~tensor.TensorVariable`
The variable whose dtype and ndim will be used to construct
the new shared variable.
name : :obj:`str` or :obj:`None`
The name of the shared variable. If None, the name is determined
based on variable's name.
"""
variable = tensor.as_tensor_variable(variable)
if name is None:
name = "shared_{}".format(variable.name)
return theano.shared(numpy.zeros((0,) * variable.ndim,
dtype=variable.dtype),
name=name)
评论列表
文章目录