提交 2ba9c67b authored 作者: Razvan Pascanu's avatar Razvan Pascanu

Fix bug reported by Olivier introduced by my last push. I was calling

tensor.as_tensor_variable on inputs of x, but I should do that only if they where numpy.ndarrays (maybe other types) .. because they could be random states case in which tensor.as_tensor_variable fails.
上级 8872aff8
......@@ -49,7 +49,8 @@ def info(*msg):
def safe_new(x):
x = tensor.as_tensor_variable(x)
if isinstance(x, numpy.ndarray):
x = tensor.as_tensor_variable(x)
if cuda.cuda_available and isinstance(x.type, cuda.CudaNdarrayType):
return tensor.TensorType(
broadcastable = x.type.broadcastable
......@@ -58,7 +59,8 @@ def safe_new(x):
return x.type()
def safe_to_cpu(x):
x = tensor.as_tensor_variable(x)
if isinstance(x, numpy.ndarray):
x = tensor.as_tensor_variable(x)
if cuda.cuda_available and isinstance(x.type, cuda.CudaNdarrayType):
return cuda.basic_ops.host_from_gpu(x)
else:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论