Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d07818e2
提交
d07818e2
authored
11月 09, 2011
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Typo fix: casted -> cast
Up/downcasted is correct though. English is weird.
上级
aaadb142
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
31 行增加
和
31 行删除
+31
-31
function.py
theano/compile/function.py
+1
-1
io.py
theano/compile/io.py
+3
-3
pfunc.py
theano/compile/pfunc.py
+3
-3
sharedvalue.py
theano/compile/sharedvalue.py
+2
-2
test_shared.py
theano/compile/tests/test_shared.py
+1
-1
configparser.py
theano/configparser.py
+4
-4
opt.py
theano/sandbox/cuda/opt.py
+2
-2
test_basic_ops.py
theano/sandbox/cuda/tests/test_basic_ops.py
+2
-2
type.py
theano/sandbox/cuda/type.py
+1
-1
test_basic.py
theano/sparse/tests/test_basic.py
+1
-1
basic.py
theano/tensor/basic.py
+1
-1
blas.py
theano/tensor/blas.py
+1
-1
opt.py
theano/tensor/opt.py
+1
-1
test_sharedvar.py
theano/tensor/tests/test_sharedvar.py
+8
-8
没有找到文件。
theano/compile/function.py
浏览文件 @
d07818e2
...
...
@@ -59,7 +59,7 @@ def function(inputs, outputs=None, mode=None, updates=[], givens=[],
:param allow_input_downcast: True means that the values passed as
inputs when calling the function can be silently downcasted to fit
the dtype of the corresponding Variable, which may lose precision.
False means that it will only be cast
ed
to a more general, or
False means that it will only be cast to a more general, or
precise, type. None (default) is almost like False, but allows
downcasting of Python float scalars to floatX.
...
...
theano/compile/io.py
浏览文件 @
d07818e2
...
...
@@ -29,13 +29,13 @@ class SymbolicInput(object):
strict: Bool (default: False)
True: means that the value you pass for this input must have exactly the right type
False: the value you pass for this input may be cast
ed
automatically to the proper type
False: the value you pass for this input may be cast automatically to the proper type
allow_downcast: Bool or None (default: None)
Only applies when `strict` is False.
True: the value you pass for this input can be silently
downcasted to fit the right type, which may lose precision.
False: the value will only be cast
ed
to a more general, or precise, type.
False: the value will only be cast to a more general, or precise, type.
None: Almost like False, but allows downcast of Python floats to floatX.
autoname: Bool (default: True)
...
...
@@ -173,7 +173,7 @@ class In(SymbolicInput):
Only applies when `strict` is False.
True: the value you pass for this input can be silently
downcasted to fit the right type, which may lose precision.
False: the value will only be cast
ed
to a more general, or precise, type.
False: the value will only be cast to a more general, or precise, type.
None: Almost like False, but allows downcast of Python floats to floatX.
autoname: Bool (default: True)
...
...
theano/compile/pfunc.py
浏览文件 @
d07818e2
...
...
@@ -274,12 +274,12 @@ class Param(object):
False: do not permit any output to be aliased to the input
:param strict: False -> function arguments may be copied or cast
ed
to match the
:param strict: False -> function arguments may be copied or cast to match the
type required by the parameter `variable`. True -> function arguments must exactly match the type
required by `variable`.
:param allow_downcast: Only applies if `strict` is False.
True -> allow assigned value to lose precision when cast
ed
during assignment.
True -> allow assigned value to lose precision when cast during assignment.
False -> never allow precision loss.
None -> only allow downcasting of a Python float to a scalar floatX.
...
...
@@ -346,7 +346,7 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[],
:param allow_input_downcast: True means that the values passed as
inputs when calling the function can be silently downcasted to fit
the dtype of the corresponding Variable, which may lose precision.
False means that it will only be cast
ed
to a more general, or
False means that it will only be cast to a more general, or
precise, type. None (default) is almost like False, but allows
downcasting of Python float scalars to floatX.
...
...
theano/compile/sharedvalue.py
浏览文件 @
d07818e2
...
...
@@ -53,11 +53,11 @@ class SharedVariable(Variable):
:param value: A value to associate with this variable (a new container will be created).
:param strict: True -> assignments to .value will not be cast
ed
or copied, so they must
:param strict: True -> assignments to .value will not be cast or copied, so they must
have the correct type.
:param allow_downcast: Only applies if `strict` is False.
True -> allow assigned value to lose precision when cast
ed
during assignment.
True -> allow assigned value to lose precision when cast during assignment.
False -> never allow precision loss.
None -> only allow downcasting of a Python float to a scalar floatX.
...
...
theano/compile/tests/test_shared.py
浏览文件 @
d07818e2
...
...
@@ -95,7 +95,7 @@ class Test_SharedVariable(unittest.TestCase):
value
=
numpy
.
asarray
([
1.
,
2.
]),
strict
=
False
)
# check that assignments to value are cast
ed
properly
# check that assignments to value are cast properly
u
.
set_value
([
3
,
4
])
assert
type
(
u
.
get_value
())
is
numpy
.
ndarray
assert
str
(
u
.
get_value
(
borrow
=
True
)
.
dtype
)
==
'float64'
...
...
theano/configparser.py
浏览文件 @
d07818e2
...
...
@@ -263,14 +263,14 @@ class TypedParam(ConfigParam):
def
__init__
(
self
,
default
,
mytype
,
is_valid
=
None
,
allow_override
=
True
):
self
.
mytype
=
mytype
def
filter
(
val
):
cast
ed
_val
=
mytype
(
val
)
cast_val
=
mytype
(
val
)
if
callable
(
is_valid
):
if
is_valid
(
cast
ed
_val
):
return
cast
ed
_val
if
is_valid
(
cast_val
):
return
cast_val
else
:
raise
ValueError
(
'Invalid value (
%
s) for configuration variable "
%
s".'
%
(
val
,
self
.
fullname
),
val
)
return
cast
ed
_val
return
cast_val
super
(
TypedParam
,
self
)
.
__init__
(
default
,
filter
,
allow_override
=
allow_override
)
def
__str__
(
self
):
return
'
%
s (
%
s) '
%
(
self
.
fullname
,
self
.
mytype
)
...
...
theano/sandbox/cuda/opt.py
浏览文件 @
d07818e2
...
...
@@ -163,8 +163,8 @@ def local_gpu_elemwise_0(node):
elif
numpy
.
all
([
i
.
type
.
dtype
in
upcastable
for
i
in
node
.
inputs
]):
# second - establish that a new node with upcasted inputs has the same outputs
# types as the original node
casted
=
node
.
op
.
make_node
(
*
[
tensor
.
cast
(
i
,
'float32'
)
for
i
in
node
.
inputs
])
if
[
o
.
type
for
o
in
casted
.
outputs
]
==
[
o
.
type
for
o
in
node
.
outputs
]:
up
casted
=
node
.
op
.
make_node
(
*
[
tensor
.
cast
(
i
,
'float32'
)
for
i
in
node
.
inputs
])
if
[
o
.
type
for
o
in
up
casted
.
outputs
]
==
[
o
.
type
for
o
in
node
.
outputs
]:
new_inputs
=
[
gpu_from_host
(
tensor
.
cast
(
i
,
'float32'
))
for
i
in
node
.
inputs
]
gpu_elemwise
=
new_op
(
*
new_inputs
)
...
...
theano/sandbox/cuda/tests/test_basic_ops.py
浏览文件 @
d07818e2
...
...
@@ -901,7 +901,7 @@ test_shared_options = theano.tensor.tests.test_sharedvar.makeSharedTester(
shared_borrow_true_alias_
=
True
,
#True when the original value is already a CudaNdarray!
set_value_borrow_true_alias_
=
True
,
set_value_inplace_
=
True
,
set_cast
ed
_value_inplace_
=
False
,
set_cast_value_inplace_
=
False
,
shared_constructor_accept_ndarray_
=
True
,
internal_type_
=
cuda_ndarray
.
CudaNdarray
,
test_internal_type_
=
lambda
a
:
isinstance
(
a
,
cuda_ndarray
.
CudaNdarray
),
...
...
@@ -919,7 +919,7 @@ test_shared_options2 = theano.tensor.tests.test_sharedvar.makeSharedTester(
shared_borrow_true_alias_
=
False
,
set_value_borrow_true_alias_
=
False
,
set_value_inplace_
=
True
,
set_cast
ed
_value_inplace_
=
True
,
set_cast_value_inplace_
=
True
,
shared_constructor_accept_ndarray_
=
True
,
internal_type_
=
cuda_ndarray
.
CudaNdarray
,
test_internal_type_
=
lambda
a
:
isinstance
(
a
,
cuda_ndarray
.
CudaNdarray
),
...
...
theano/sandbox/cuda/type.py
浏览文件 @
d07818e2
...
...
@@ -65,7 +65,7 @@ class CudaNdarrayType(Type):
return
cuda
.
filter
(
data
,
self
.
broadcastable
,
strict
,
old_data
)
else
:
# (not strict) and (not allow_downcast)
# Check if data.dtype can be accurately cast
ed
to self.dtype
# Check if data.dtype can be accurately cast to self.dtype
if
isinstance
(
data
,
numpy
.
ndarray
):
up_dtype
=
scal
.
upcast
(
self
.
dtype
,
data
.
dtype
)
if
up_dtype
==
self
.
dtype
:
...
...
theano/sparse/tests/test_basic.py
浏览文件 @
d07818e2
...
...
@@ -923,7 +923,7 @@ test_shared_options = theano.tensor.tests.test_sharedvar.makeSharedTester(
shared_borrow_true_alias_
=
True
,
set_value_borrow_true_alias_
=
True
,
set_value_inplace_
=
False
,
set_cast
ed
_value_inplace_
=
False
,
set_cast_value_inplace_
=
False
,
shared_constructor_accept_ndarray_
=
False
,
internal_type_
=
scipy
.
sparse
.
csc_matrix
,
test_internal_type_
=
scipy
.
sparse
.
issparse
,
...
...
theano/tensor/basic.py
浏览文件 @
d07818e2
...
...
@@ -244,7 +244,7 @@ class NumpyAutocaster(object):
x_
=
theano
.
_asarray
(
x
,
dtype
=
dtype
)
if
numpy
.
all
(
x
==
x_
):
break
# returns either an exact x_==x, or the last cast
ed
x_
# returns either an exact x_==x, or the last cast x_
return
x_
autocast_int
=
NumpyAutocaster
((
'int8'
,
'int16'
,
'int32'
,
'int64'
))
...
...
theano/tensor/blas.py
浏览文件 @
d07818e2
...
...
@@ -1126,7 +1126,7 @@ def _gemm_from_factored_list(lst):
return
False
lst2
=
[]
# Remove the tuple that can't be cast
ed
correctly.
# Remove the tuple that can't be cast correctly.
# This can happen when we try to cast a complex to a real
for
sM
in
lst
:
if
is_pair
(
sM
):
...
...
theano/tensor/opt.py
浏览文件 @
d07818e2
...
...
@@ -92,7 +92,7 @@ def scalarconsts_rest(inputs):
def
broadcast_like
(
value
,
template
,
env
,
dtype
=
None
):
"""Return a Variable with the same shape and dtype as the template,
filled by broadcasting value through it. `value` will be cast
ed
as
filled by broadcasting value through it. `value` will be cast as
necessary.
"""
...
...
theano/tensor/tests/test_sharedvar.py
浏览文件 @
d07818e2
...
...
@@ -17,7 +17,7 @@ def makeSharedTester(shared_constructor_,
shared_borrow_true_alias_
,
set_value_borrow_true_alias_
,
set_value_inplace_
,
set_cast
ed
_value_inplace_
,
set_cast_value_inplace_
,
shared_constructor_accept_ndarray_
,
internal_type_
,
test_internal_type_
,
...
...
@@ -38,7 +38,7 @@ def makeSharedTester(shared_constructor_,
:param set_value_borrow_true_alias_: Should set_value(val,borrow=True) reuse the val memory space
:param set_value_inplace_: Should this shared variable overwrite the current
memory when the new value is an ndarray
:param set_cast
ed
_value_inplace_: Should this shared variable overwrite the
:param set_cast_value_inplace_: Should this shared variable overwrite the
current memory when the new value is of the same
type as the internal type.
:param shared_constructor_accept_ndarray_: Do the shared_constructor accept an ndarray as input?
...
...
@@ -71,7 +71,7 @@ def makeSharedTester(shared_constructor_,
ref_fct
=
staticmethod
(
ref_fct_
)
set_value_borrow_true_alias
=
set_value_borrow_true_alias_
set_value_inplace
=
set_value_inplace_
set_cast
ed_value_inplace
=
set_casted
_value_inplace_
set_cast
_value_inplace
=
set_cast
_value_inplace_
shared_constructor_accept_ndarray
=
shared_constructor_accept_ndarray_
cast_value
=
staticmethod
(
cast_value_
)
op_by_matrix
=
op_by_matrix_
...
...
@@ -379,14 +379,14 @@ def makeSharedTester(shared_constructor_,
self
.
ref_fct
(
self
.
cast_value
(
nd
)))
assert
may_share_memory
(
old_data
,
x_shared
.
container
.
storage
[
0
])
==
self
.
set_value_inplace
# Test by set_value with borrow=False when new data cast
ed
.
# Test by set_value with borrow=False when new data cast.
# specificaly useful for gpu data
nd
+=
1
old_data
=
x_shared
.
container
.
storage
[
0
]
x_shared
.
set_value
(
self
.
cast_value
(
nd
),
borrow
=
False
)
assert
numpy
.
allclose
(
self
.
ref_fct
(
x_shared
.
get_value
(
borrow
=
True
)),
self
.
ref_fct
(
self
.
cast_value
(
nd
)))
assert
may_share_memory
(
old_data
,
x_shared
.
container
.
storage
[
0
])
==
self
.
set_cast
ed
_value_inplace
assert
may_share_memory
(
old_data
,
x_shared
.
container
.
storage
[
0
])
==
self
.
set_cast_value_inplace
# Test by set_value with borrow=True
nd
+=
1
...
...
@@ -396,12 +396,12 @@ def makeSharedTester(shared_constructor_,
self
.
ref_fct
(
self
.
cast_value
(
nd
)))
assert
may_share_memory
(
old_data
,
x_shared
.
container
.
storage
[
0
])
==
self
.
set_value_inplace
# Test by set_value with borrow=True when new data cast
ed
.
# Test by set_value with borrow=True when new data cast.
nd
+=
1
old_data
=
x_shared
.
container
.
storage
[
0
]
x_shared
.
set_value
(
self
.
cast_value
(
nd
.
copy
()),
borrow
=
True
)
assert
numpy
.
allclose
(
self
.
ref_fct
(
x_shared
.
get_value
(
borrow
=
True
)),
self
.
ref_fct
(
self
.
cast_value
(
nd
)))
assert
may_share_memory
(
old_data
,
x_shared
.
container
.
storage
[
0
])
==
self
.
set_cast
ed
_value_inplace
assert
may_share_memory
(
old_data
,
x_shared
.
container
.
storage
[
0
])
==
self
.
set_cast_value_inplace
def
test_specify_shape
(
self
):
dtype
=
self
.
dtype
...
...
@@ -628,7 +628,7 @@ test_shared_options=makeSharedTester(
shared_borrow_true_alias_
=
True
,
set_value_borrow_true_alias_
=
True
,
set_value_inplace_
=
False
,
set_cast
ed
_value_inplace_
=
False
,
set_cast_value_inplace_
=
False
,
shared_constructor_accept_ndarray_
=
True
,
internal_type_
=
numpy
.
ndarray
,
test_internal_type_
=
lambda
a
:
isinstance
(
a
,
numpy
.
ndarray
),
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论