Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
969cf83c
提交
969cf83c
authored
10月 21, 2020
作者:
Brandon T. Willard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Apply isort to theano.scalar sub-package modules
上级
7029d8c0
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
21 行增加
和
16 行删除
+21
-16
__init__.py
theano/scalar/__init__.py
+0
-1
basic.py
theano/scalar/basic.py
+8
-5
basic_scipy.py
theano/scalar/basic_scipy.py
+8
-8
basic_sympy.py
theano/scalar/basic_sympy.py
+3
-2
sharedvar.py
theano/scalar/sharedvar.py
+2
-0
没有找到文件。
theano/scalar/__init__.py
浏览文件 @
969cf83c
from
.basic
import
*
from
.basic
import
*
from
.basic_scipy
import
*
from
.basic_scipy
import
*
theano/scalar/basic.py
浏览文件 @
969cf83c
...
@@ -19,13 +19,16 @@ from textwrap import dedent
...
@@ -19,13 +19,16 @@ from textwrap import dedent
import
numpy
as
np
import
numpy
as
np
import
six
import
six
import
theano
import
theano
from
theano
import
config
,
gof
,
printing
from
theano
import
config
,
gof
,
printing
from
theano.compat
import
Callable
from
theano.compat
import
Callable
from
theano.gof
import
Apply
,
Constant
,
FunctionGraph
,
Op
,
Type
,
Variable
,
utils
from
theano.gof
import
Apply
,
Constant
,
FunctionGraph
,
Op
,
Type
,
Variable
,
utils
from
theano.gradient
import
DisconnectedType
,
grad_undefined
from
theano.gradient
import
DisconnectedType
,
grad_undefined
from
theano.misc.safe_asarray
import
_asarray
from
theano.printing
import
pprint
from
theano.printing
import
pprint
builtin_bool
=
bool
builtin_bool
=
bool
builtin_complex
=
complex
builtin_complex
=
complex
builtin_int
=
int
builtin_int
=
int
...
@@ -181,7 +184,7 @@ class NumpyAutocaster(object):
...
@@ -181,7 +184,7 @@ class NumpyAutocaster(object):
and
rval
.
dtype
in
(
"float64"
,
"float32"
)
and
rval
.
dtype
in
(
"float64"
,
"float32"
)
and
rval
.
dtype
!=
config
.
floatX
and
rval
.
dtype
!=
config
.
floatX
):
):
rval
=
theano
.
_asarray
(
rval
,
dtype
=
config
.
floatX
)
rval
=
_asarray
(
rval
,
dtype
=
config
.
floatX
)
return
rval
return
rval
# The following is the original code, corresponding to the 'custom'
# The following is the original code, corresponding to the 'custom'
...
@@ -207,7 +210,7 @@ class NumpyAutocaster(object):
...
@@ -207,7 +210,7 @@ class NumpyAutocaster(object):
and
config
.
floatX
in
self
.
dtypes
and
config
.
floatX
in
self
.
dtypes
and
config
.
floatX
!=
"float64"
and
config
.
floatX
!=
"float64"
):
):
return
theano
.
_asarray
(
x
,
dtype
=
config
.
floatX
)
return
_asarray
(
x
,
dtype
=
config
.
floatX
)
# Don't autocast to float16 unless config.floatX is float16
# Don't autocast to float16 unless config.floatX is float16
try_dtypes
=
[
try_dtypes
=
[
...
@@ -215,7 +218,7 @@ class NumpyAutocaster(object):
...
@@ -215,7 +218,7 @@ class NumpyAutocaster(object):
]
]
for
dtype
in
try_dtypes
:
for
dtype
in
try_dtypes
:
x_
=
theano
.
_asarray
(
x
,
dtype
=
dtype
)
x_
=
_asarray
(
x
,
dtype
=
dtype
)
if
np
.
all
(
x
==
x_
):
if
np
.
all
(
x
==
x_
):
break
break
# returns either an exact x_==x, or the last cast x_
# returns either an exact x_==x, or the last cast x_
...
@@ -272,7 +275,7 @@ def convert(x, dtype=None):
...
@@ -272,7 +275,7 @@ def convert(x, dtype=None):
"""
"""
if
dtype
is
not
None
:
if
dtype
is
not
None
:
# in this case, the semantics are that the caller is forcing the dtype
# in this case, the semantics are that the caller is forcing the dtype
x_
=
theano
.
_asarray
(
x
,
dtype
=
dtype
)
x_
=
_asarray
(
x
,
dtype
=
dtype
)
else
:
else
:
# In this case, this function should infer the dtype according to the
# In this case, this function should infer the dtype according to the
# autocasting rules. See autocasting above.
# autocasting rules. See autocasting above.
...
@@ -283,7 +286,7 @@ def convert(x, dtype=None):
...
@@ -283,7 +286,7 @@ def convert(x, dtype=None):
except
OverflowError
:
except
OverflowError
:
# This is to imitate numpy behavior which tries to fit
# This is to imitate numpy behavior which tries to fit
# bigger numbers into a uint64.
# bigger numbers into a uint64.
x_
=
theano
.
_asarray
(
x
,
dtype
=
"uint64"
)
x_
=
_asarray
(
x
,
dtype
=
"uint64"
)
elif
isinstance
(
x
,
builtin_float
):
elif
isinstance
(
x
,
builtin_float
):
x_
=
autocast_float
(
x
)
x_
=
autocast_float
(
x
)
elif
isinstance
(
x
,
np
.
ndarray
):
elif
isinstance
(
x
,
np
.
ndarray
):
...
...
theano/scalar/basic_scipy.py
浏览文件 @
969cf83c
# Definitions of theano.scalar ops that have their python implementation taken
# Definitions of theano.scalar ops that have their python implementation taken
# from SciPy. As SciPy is not always available, we treat them separately.
# from SciPy. As SciPy is not always available, we treat them separately.
import
numpy
as
np
import
os
import
os
import
numpy
as
np
import
theano
import
theano
from
theano.gradient
import
grad_not_implemented
from
theano.gradient
import
grad_not_implemented
from
theano.scalar.basic
import
(
from
theano.scalar.basic
import
(
UnaryScalarOp
,
BinaryScalarOp
,
BinaryScalarOp
,
UnaryScalarOp
,
complex_types
,
discrete_types
,
exp
,
exp
,
float_types
,
upcast
,
upgrade_to_float
,
upgrade_to_float
,
upgrade_to_float64
,
upgrade_to_float64
,
float_types
,
)
from
theano.scalar.basic
import
(
upgrade_to_float_no_complex
,
upgrade_to_float_no_complex
,
complex_types
,
discrete_types
,
upcast
,
)
)
imported_scipy_special
=
False
imported_scipy_special
=
False
try
:
try
:
import
scipy.special
import
scipy.special
...
...
theano/scalar/basic_sympy.py
浏览文件 @
969cf83c
import
itertools
as
it
import
itertools
as
it
from
theano.scalar.basic
import
Apply
,
ScalarOp
,
as_scalar
,
float64
,
float32
,
int64
from
theano.gof.utils
import
remove
from
theano.gof.utils
import
remove
from
theano.scalar.basic
import
Apply
,
ScalarOp
,
as_scalar
,
float32
,
float64
,
int64
imported_sympy
=
False
imported_sympy
=
False
try
:
try
:
from
sympy.utilities.codegen
import
get_default_datatype
,
codegen
from
sympy.utilities.codegen
import
codegen
,
get_default_datatype
imported_sympy
=
True
imported_sympy
=
True
except
ImportError
:
except
ImportError
:
...
...
theano/scalar/sharedvar.py
浏览文件 @
969cf83c
...
@@ -20,8 +20,10 @@ import numpy as np
...
@@ -20,8 +20,10 @@ import numpy as np
from
six
import
integer_types
from
six
import
integer_types
from
theano.compile
import
SharedVariable
from
theano.compile
import
SharedVariable
from
.basic
import
Scalar
,
_scalar_py_operators
from
.basic
import
Scalar
,
_scalar_py_operators
__authors__
=
"James Bergstra"
__authors__
=
"James Bergstra"
__copyright__
=
"(c) 2010, Universite de Montreal"
__copyright__
=
"(c) 2010, Universite de Montreal"
__license__
=
"3-clause BSD License"
__license__
=
"3-clause BSD License"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论