Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7b50faa0
提交
7b50faa0
authored
1月 24, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
disabling floatX.py. using config.floatX to adjust the dtype default in tensor.matrix,vector,etc.
上级
ac95733a
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
76 行增加
和
35 行删除
+76
-35
__init__.py
theano/__init__.py
+0
-2
floatX.py
theano/floatX.py
+27
-26
basic.py
theano/tensor/basic.py
+49
-7
没有找到文件。
theano/__init__.py
浏览文件 @
7b50faa0
...
@@ -65,8 +65,6 @@ import scalar
...
@@ -65,8 +65,6 @@ import scalar
import
sparse
import
sparse
import
gradient
import
gradient
import
gof
import
gof
import
floatX
floatX
.
set_floatX
()
if
config
.
device
.
startswith
(
'gpu'
):
if
config
.
device
.
startswith
(
'gpu'
):
import
theano.sandbox.cuda
import
theano.sandbox.cuda
...
...
theano/floatX.py
浏览文件 @
7b50faa0
"""Provide xscalar, xvector, xmatrix, etc. pseudo-types
"""Provide xscalar, xvector, xmatrix, etc. pseudo-types
"""
"""
from
.configparser
import
config
if
0
:
from
theano.scalar
import
float64
,
float32
from
.configparser
import
config
from
theano.tensor
import
(
fscalar
,
fvector
,
fmatrix
,
frow
,
fcol
,
ftensor3
,
ftensor4
,
dscalar
,
from
theano.scalar
import
float64
,
float32
dvector
,
dmatrix
,
drow
,
dcol
,
dtensor3
,
dtensor4
)
from
theano.tensor
import
(
fscalar
,
fvector
,
fmatrix
,
frow
,
fcol
,
ftensor3
,
ftensor4
,
dscalar
,
dvector
,
dmatrix
,
drow
,
dcol
,
dtensor3
,
dtensor4
)
#
# !!! set_floatX adds symbols directly to the module's symbol table !!!
#
#
# !!! set_floatX adds symbols directly to the module's symbol table !!!
#
def
set_floatX
(
dtype
=
config
.
floatX
):
""" add the xmatrix, xvector, xscalar etc. aliases to theano.tensor
def
set_floatX
(
dtype
=
config
.
floatX
):
"""
""" add the xmatrix, xvector, xscalar etc. aliases to theano.tensor
config
.
floatX
=
dtype
"""
if
dtype
==
'float32'
:
prefix
=
'f'
config
.
floatX
=
dtype
elif
dtype
==
'float64'
:
prefix
=
'd'
if
dtype
==
'float32'
:
prefix
=
'f'
else
:
raise
Exception
(
"Bad param in set_floatX(
%
s). Only float32 and float64 are supported"
%
config
.
floatX
)
elif
dtype
==
'float64'
:
prefix
=
'd'
else
:
raise
Exception
(
"Bad param in set_floatX(
%
s). Only float32 and float64 are supported"
%
config
.
floatX
)
#tensor.scalar stuff
globals
()[
'floatX'
]
=
globals
()[
dtype
]
#tensor.scalar stuff
# convert_to_floatX = Cast(floatX, name='convert_to_floatX')
globals
()[
'floatX'
]
=
globals
()[
dtype
]
# convert_to_floatX = Cast(floatX, name='convert_to_floatX')
#tensor.tensor stuff
for
symbol
in
(
'scalar'
,
'vector'
,
'matrix'
,
'row'
,
'col'
,
'tensor3'
,
'tensor4'
):
#tensor.tensor stuff
globals
()[
'x'
+
symbol
]
=
globals
()[
prefix
+
symbol
]
for
symbol
in
(
'scalar'
,
'vector'
,
'matrix'
,
'row'
,
'col'
,
'tensor3'
,
'tensor4'
):
#_convert_to_floatX = _conversion(elemwise.Elemwise(scal.convert_to_floatX), 'floatX')
globals
()[
'x'
+
symbol
]
=
globals
()[
prefix
+
symbol
]
#_convert_to_floatX = _conversion(elemwise.Elemwise(scal.convert_to_floatX), 'floatX')
...
...
theano/tensor/basic.py
浏览文件 @
7b50faa0
...
@@ -657,7 +657,13 @@ bscalar = TensorType('int8', ())
...
@@ -657,7 +657,13 @@ bscalar = TensorType('int8', ())
wscalar
=
TensorType
(
'int16'
,
())
wscalar
=
TensorType
(
'int16'
,
())
iscalar
=
TensorType
(
'int32'
,
())
iscalar
=
TensorType
(
'int32'
,
())
lscalar
=
TensorType
(
'int64'
,
())
lscalar
=
TensorType
(
'int64'
,
())
def
scalar
(
name
=
None
,
dtype
=
'float64'
):
def
scalar
(
name
=
None
,
dtype
=
None
):
"""Return a symbolic scalar variable.
:param dtype: numeric type (None means to use theano.config.floatX)
:param name: a name to attach to this variable
"""
if
dtype
is
None
:
dtype
=
config
.
floatX
type
=
TensorType
(
dtype
,
())
type
=
TensorType
(
dtype
,
())
return
type
(
name
)
return
type
(
name
)
scalars
,
fscalars
,
dscalars
,
iscalars
,
lscalars
=
_multi
(
scalar
,
fscalar
,
dscalar
,
iscalar
,
lscalar
)
scalars
,
fscalars
,
dscalars
,
iscalars
,
lscalars
=
_multi
(
scalar
,
fscalar
,
dscalar
,
iscalar
,
lscalar
)
...
@@ -677,7 +683,13 @@ bvector = TensorType('int8', (False,))
...
@@ -677,7 +683,13 @@ bvector = TensorType('int8', (False,))
wvector
=
TensorType
(
'int16'
,
(
False
,))
wvector
=
TensorType
(
'int16'
,
(
False
,))
ivector
=
TensorType
(
'int32'
,
(
False
,
))
ivector
=
TensorType
(
'int32'
,
(
False
,
))
lvector
=
TensorType
(
'int64'
,
(
False
,
))
lvector
=
TensorType
(
'int64'
,
(
False
,
))
def
vector
(
name
=
None
,
dtype
=
'float64'
):
def
vector
(
name
=
None
,
dtype
=
None
):
"""Return a symbolic vector variable.
:param dtype: numeric type (None means to use theano.config.floatX)
:param name: a name to attach to this variable
"""
if
dtype
is
None
:
dtype
=
config
.
floatX
type
=
TensorType
(
dtype
,
(
False
,
))
type
=
TensorType
(
dtype
,
(
False
,
))
return
type
(
name
)
return
type
(
name
)
vectors
,
fvectors
,
dvectors
,
ivectors
,
lvectors
=
_multi
(
vector
,
fvector
,
dvector
,
ivector
,
lvector
)
vectors
,
fvectors
,
dvectors
,
ivectors
,
lvectors
=
_multi
(
vector
,
fvector
,
dvector
,
ivector
,
lvector
)
...
@@ -694,7 +706,13 @@ bmatrix = TensorType('int8', (False, False))
...
@@ -694,7 +706,13 @@ bmatrix = TensorType('int8', (False, False))
wmatrix
=
TensorType
(
'int16'
,
(
False
,
False
))
wmatrix
=
TensorType
(
'int16'
,
(
False
,
False
))
imatrix
=
TensorType
(
'int32'
,
(
False
,
False
))
imatrix
=
TensorType
(
'int32'
,
(
False
,
False
))
lmatrix
=
TensorType
(
'int64'
,
(
False
,
False
))
lmatrix
=
TensorType
(
'int64'
,
(
False
,
False
))
def
matrix
(
name
=
None
,
dtype
=
'float64'
):
def
matrix
(
name
=
None
,
dtype
=
None
):
"""Return a symbolic matrix variable.
:param dtype: numeric type (None means to use theano.config.floatX)
:param name: a name to attach to this variable
"""
if
dtype
is
None
:
dtype
=
config
.
floatX
type
=
TensorType
(
dtype
,
(
False
,
False
))
type
=
TensorType
(
dtype
,
(
False
,
False
))
return
type
(
name
)
return
type
(
name
)
matrices
,
fmatrices
,
dmatrices
,
imatrices
,
lmatrices
=
_multi
(
matrix
,
fmatrix
,
dmatrix
,
imatrix
,
lmatrix
)
matrices
,
fmatrices
,
dmatrices
,
imatrices
,
lmatrices
=
_multi
(
matrix
,
fmatrix
,
dmatrix
,
imatrix
,
lmatrix
)
...
@@ -711,7 +729,13 @@ brow = TensorType('int8', (True, False))
...
@@ -711,7 +729,13 @@ brow = TensorType('int8', (True, False))
wrow
=
TensorType
(
'int16'
,
(
True
,
False
))
wrow
=
TensorType
(
'int16'
,
(
True
,
False
))
irow
=
TensorType
(
'int32'
,
(
True
,
False
))
irow
=
TensorType
(
'int32'
,
(
True
,
False
))
lrow
=
TensorType
(
'int64'
,
(
True
,
False
))
lrow
=
TensorType
(
'int64'
,
(
True
,
False
))
def
row
(
name
=
None
,
dtype
=
'float64'
):
def
row
(
name
=
None
,
dtype
=
None
):
"""Return a symbolic row variable (ndim=2, broadcastable=[True,False]).
:param dtype: numeric type (None means to use theano.config.floatX)
:param name: a name to attach to this variable
"""
if
dtype
is
None
:
dtype
=
config
.
floatX
type
=
TensorType
(
dtype
,
(
True
,
False
))
type
=
TensorType
(
dtype
,
(
True
,
False
))
return
type
(
name
)
return
type
(
name
)
rows
,
frows
,
drows
,
irows
,
lrows
=
_multi
(
row
,
frow
,
drow
,
irow
,
lrow
)
rows
,
frows
,
drows
,
irows
,
lrows
=
_multi
(
row
,
frow
,
drow
,
irow
,
lrow
)
...
@@ -724,7 +748,13 @@ bcol = TensorType('int8', (False, True))
...
@@ -724,7 +748,13 @@ bcol = TensorType('int8', (False, True))
wcol
=
TensorType
(
'int16'
,
(
False
,
True
))
wcol
=
TensorType
(
'int16'
,
(
False
,
True
))
icol
=
TensorType
(
'int32'
,
(
False
,
True
))
icol
=
TensorType
(
'int32'
,
(
False
,
True
))
lcol
=
TensorType
(
'int64'
,
(
False
,
True
))
lcol
=
TensorType
(
'int64'
,
(
False
,
True
))
def
col
(
name
=
None
,
dtype
=
'float64'
):
def
col
(
name
=
None
,
dtype
=
None
):
"""Return a symbolic column variable (ndim=2, broadcastable=[False,True]).
:param dtype: numeric type (None means to use theano.config.floatX)
:param name: a name to attach to this variable
"""
if
dtype
is
None
:
dtype
=
config
.
floatX
type
=
TensorType
(
dtype
,
(
False
,
True
))
type
=
TensorType
(
dtype
,
(
False
,
True
))
return
type
(
name
)
return
type
(
name
)
cols
,
fcols
,
dcols
,
icols
,
lcols
=
_multi
(
col
,
fcol
,
dcol
,
icol
,
lcol
)
cols
,
fcols
,
dcols
,
icols
,
lcols
=
_multi
(
col
,
fcol
,
dcol
,
icol
,
lcol
)
...
@@ -737,7 +767,13 @@ btensor3 = TensorType('int8', (False,)*3)
...
@@ -737,7 +767,13 @@ btensor3 = TensorType('int8', (False,)*3)
wtensor3
=
TensorType
(
'int16'
,
(
False
,)
*
3
)
wtensor3
=
TensorType
(
'int16'
,
(
False
,)
*
3
)
itensor3
=
TensorType
(
'int32'
,
(
False
,)
*
3
)
itensor3
=
TensorType
(
'int32'
,
(
False
,)
*
3
)
ltensor3
=
TensorType
(
'int64'
,
(
False
,)
*
3
)
ltensor3
=
TensorType
(
'int64'
,
(
False
,)
*
3
)
def
tensor3
(
name
=
None
,
dtype
=
'float64'
):
def
tensor3
(
name
=
None
,
dtype
=
None
):
"""Return a symbolic 3-D variable.
:param dtype: numeric type (None means to use theano.config.floatX)
:param name: a name to attach to this variable
"""
if
dtype
is
None
:
dtype
=
config
.
floatX
type
=
TensorType
(
dtype
,
(
False
,
False
,
False
))
type
=
TensorType
(
dtype
,
(
False
,
False
,
False
))
return
type
(
name
)
return
type
(
name
)
tensor3s
,
ftensor3s
,
dtensor3s
,
itensor3s
,
ltensor3s
=
_multi
(
tensor3
,
ftensor3
,
dtensor3
,
tensor3s
,
ftensor3s
,
dtensor3s
,
itensor3s
,
ltensor3s
=
_multi
(
tensor3
,
ftensor3
,
dtensor3
,
...
@@ -751,7 +787,13 @@ btensor4 = TensorType('int8', (False,)*4)
...
@@ -751,7 +787,13 @@ btensor4 = TensorType('int8', (False,)*4)
wtensor4
=
TensorType
(
'int16'
,
(
False
,)
*
4
)
wtensor4
=
TensorType
(
'int16'
,
(
False
,)
*
4
)
itensor4
=
TensorType
(
'int32'
,
(
False
,)
*
4
)
itensor4
=
TensorType
(
'int32'
,
(
False
,)
*
4
)
ltensor4
=
TensorType
(
'int64'
,
(
False
,)
*
4
)
ltensor4
=
TensorType
(
'int64'
,
(
False
,)
*
4
)
def
tensor4
(
name
=
None
,
dtype
=
'float64'
):
def
tensor4
(
name
=
None
,
dtype
=
None
):
"""Return a symbolic 4-D variable.
:param dtype: numeric type (None means to use theano.config.floatX)
:param name: a name to attach to this variable
"""
if
dtype
is
None
:
dtype
=
config
.
floatX
type
=
TensorType
(
dtype
,
(
False
,
False
,
False
,
False
))
type
=
TensorType
(
dtype
,
(
False
,
False
,
False
,
False
))
return
type
(
name
)
return
type
(
name
)
tensor4s
,
ftensor4s
,
dtensor4s
,
itensor4s
,
ltensor4s
=
_multi
(
tensor4
,
ftensor4
,
dtensor4
,
tensor4s
,
ftensor4s
,
dtensor4s
,
itensor4s
,
ltensor4s
=
_multi
(
tensor4
,
ftensor4
,
dtensor4
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论