提交 cbae6dfe authored 作者: Frederic Bastien's avatar Frederic Bastien

fix DeepCopyOp when the args don't have a copy attribute. Happen with mtrand.RandomState.

上级 7e6ca506
......@@ -180,7 +180,14 @@ class DeepCopyOp(theano.gof.Op):
return theano.gof.Apply(self, [x], [x.type()])
def perform( self, node, args, outs):
outs[0][0] = copy.deepcopy(args[0])
if hasattr(args[0],'copy'):
#when args[0] is a an ndarray of 0 dimensions,
#this return a numpy.dtype and not an ndarray
#So when the args have a copy attribute we use it
#as this don't have this problem
outs[0][0] = args[0].copy()
else:
outs[0][0] = copy.deepcopy(args[0])
def c_code_cache_version(self):
return (1)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论