提交 5715084e authored 作者: amrithasuresh's avatar amrithasuresh

Updated numpy as np

上级 58d3e123
from __future__ import absolute_import, print_function, division from __future__ import absolute_import, print_function, division
import traceback import traceback
import numpy import numpy as np
from six import integer_types from six import integer_types
import theano.tensor.basic import theano.tensor.basic
...@@ -41,7 +41,7 @@ def tensor_constructor(value, name=None, strict=False, allow_downcast=None, ...@@ -41,7 +41,7 @@ def tensor_constructor(value, name=None, strict=False, allow_downcast=None,
if target != 'cpu': if target != 'cpu':
raise TypeError('not for cpu') raise TypeError('not for cpu')
if not isinstance(value, numpy.ndarray): if not isinstance(value, np.ndarray):
raise TypeError() raise TypeError()
# if no broadcastable is given, then the default is to assume that # if no broadcastable is given, then the default is to assume that
...@@ -51,7 +51,7 @@ def tensor_constructor(value, name=None, strict=False, allow_downcast=None, ...@@ -51,7 +51,7 @@ def tensor_constructor(value, name=None, strict=False, allow_downcast=None,
broadcastable = (False,) * len(value.shape) broadcastable = (False,) * len(value.shape)
type = TensorType(value.dtype, broadcastable=broadcastable) type = TensorType(value.dtype, broadcastable=broadcastable)
return TensorSharedVariable(type=type, return TensorSharedVariable(type=type,
value=numpy.array(value, copy=(not borrow)), value=np.array(value, copy=(not borrow)),
name=name, name=name,
strict=strict, strict=strict,
allow_downcast=allow_downcast) allow_downcast=allow_downcast)
...@@ -86,12 +86,12 @@ def scalar_constructor(value, name=None, strict=False, allow_downcast=None, ...@@ -86,12 +86,12 @@ def scalar_constructor(value, name=None, strict=False, allow_downcast=None,
if target != 'cpu': if target != 'cpu':
raise TypeError('not for cpu') raise TypeError('not for cpu')
if not isinstance(value, (numpy.number, float, integer_types, complex)): if not isinstance(value, (np.number, float, integer_types, complex)):
raise TypeError() raise TypeError()
try: try:
dtype = value.dtype dtype = value.dtype
except Exception: except Exception:
dtype = numpy.asarray(value).dtype dtype = np.asarray(value).dtype
dtype = str(dtype) dtype = str(dtype)
value = theano._asarray(value, dtype=dtype) value = theano._asarray(value, dtype=dtype)
...@@ -101,7 +101,7 @@ def scalar_constructor(value, name=None, strict=False, allow_downcast=None, ...@@ -101,7 +101,7 @@ def scalar_constructor(value, name=None, strict=False, allow_downcast=None,
# Do not pass the dtype to asarray because we want this to fail if # Do not pass the dtype to asarray because we want this to fail if
# strict is True and the types do not match. # strict is True and the types do not match.
rval = ScalarSharedVariable(type=tensor_type, rval = ScalarSharedVariable(type=tensor_type,
value=numpy.array(value, copy=True), value=np.array(value, copy=True),
name=name, name=name,
strict=strict, strict=strict,
allow_downcast=allow_downcast) allow_downcast=allow_downcast)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论