提交 32253545 authored 作者: Frederic's avatar Frederic

Fix another potential reuse of NoneConst between fgraph and doc how to use it.

上级 6df2af9f
...@@ -1704,7 +1704,7 @@ advanced_inc_subtensor1 = AdvancedIncSubtensor1() ...@@ -1704,7 +1704,7 @@ advanced_inc_subtensor1 = AdvancedIncSubtensor1()
def as_index_variable(idx): def as_index_variable(idx):
if idx is None: if idx is None:
return NoneConst return NoneConst.clone()
if isinstance(idx, slice): if isinstance(idx, slice):
return make_slice(idx) return make_slice(idx)
idx = theano.tensor.as_tensor_variable(idx) idx = theano.tensor.as_tensor_variable(idx)
......
...@@ -66,4 +66,7 @@ class NoneTypeT(Type): ...@@ -66,4 +66,7 @@ class NoneTypeT(Type):
def __str__(self): def __str__(self):
return "None" return "None"
# This is a variable instance. It can be used only once per fgraph.
# So use NoneConst.clone() before using it in a Theano graph.
# Use NoneConst.equal(x) to check if two variable are NoneConst.
NoneConst = Constant(NoneTypeT(), None, name='None') NoneConst = Constant(NoneTypeT(), None, name='None')
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论