提交 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,6 +49,7 @@ def info(*msg): ...@@ -49,6 +49,7 @@ def info(*msg):
def safe_new(x): def safe_new(x):
if isinstance(x, numpy.ndarray):
x = tensor.as_tensor_variable(x) x = tensor.as_tensor_variable(x)
if cuda.cuda_available and isinstance(x.type, cuda.CudaNdarrayType): if cuda.cuda_available and isinstance(x.type, cuda.CudaNdarrayType):
return tensor.TensorType( return tensor.TensorType(
...@@ -58,6 +59,7 @@ def safe_new(x): ...@@ -58,6 +59,7 @@ def safe_new(x):
return x.type() return x.type()
def safe_to_cpu(x): def safe_to_cpu(x):
if isinstance(x, numpy.ndarray):
x = tensor.as_tensor_variable(x) x = tensor.as_tensor_variable(x)
if cuda.cuda_available and isinstance(x.type, cuda.CudaNdarrayType): if cuda.cuda_available and isinstance(x.type, cuda.CudaNdarrayType):
return cuda.basic_ops.host_from_gpu(x) return cuda.basic_ops.host_from_gpu(x)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论