提交 9a653e3e authored 作者: Frédéric Bastien's avatar Frédéric Bastien

Merge pull request #3150 from caglar/theano_shared_zero2

added the shared variable zero fn.
...@@ -113,6 +113,22 @@ class SharedVariable(Variable): ...@@ -113,6 +113,22 @@ class SharedVariable(Variable):
else: else:
self.container.value = copy.deepcopy(new_value) self.container.value = copy.deepcopy(new_value)
def zero(self, borrow=False):
"""Set the values of a shared variable to 0.
:param borrow:
True to modify the value of a shared variable directly by using
its previous value. Potentially this can cause problems
regarding to the aliased memory.
Changes done with this function will be visible to all functions using
this SharedVariable.
"""
if borrow:
self.container.value[...] = 0
else:
self.container.value = 0 * self.container.value
def clone(self): def clone(self):
cp = self.__class__( cp = self.__class__(
name=self.name, name=self.name,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论