Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
14e3a1e8
提交
14e3a1e8
authored
6月 26, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix alpha_merge and output_merge.
上级
ecba472d
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
17 行增加
和
17 行删除
+17
-17
dnn.py
theano/sandbox/gpuarray/dnn.py
+11
-11
opt_util.py
theano/sandbox/gpuarray/opt_util.py
+5
-5
basic.py
theano/tensor/basic.py
+1
-1
没有找到文件。
theano/sandbox/gpuarray/dnn.py
浏览文件 @
14e3a1e8
...
...
@@ -385,17 +385,17 @@ _zero = constant(numpy.asarray(0.0, dtype='float64'))
_one
=
constant
(
numpy
.
asarray
(
1.0
,
dtype
=
'float64'
))
def
ensure_d
ouble
(
val
,
default
,
nam
e
):
def
ensure_d
t
(
val
,
default
,
name
,
dtyp
e
):
if
val
is
None
:
return
default
.
clone
()
val
=
default
.
clone
()
if
not
isinstance
(
val
,
Variable
):
val
=
constant
(
val
)
.
astype
(
'float64'
)
val
=
constant
(
val
)
if
hasattr
(
val
,
'ndim'
)
and
val
.
ndim
==
0
:
val
=
as_scalar
(
val
)
if
not
isinstance
(
val
.
type
,
theano
.
scalar
.
Scalar
):
raise
TypeError
(
"
%
s: expected a scalar value"
%
(
name
,))
if
not
val
.
type
.
dtype
==
'float64'
:
raise
TypeError
(
"
%
s: type is not float64"
%
(
name
,)
)
if
not
val
.
type
.
dtype
==
dtype
:
val
=
val
.
astype
(
dtype
)
return
val
...
...
@@ -456,8 +456,8 @@ class GpuDnnConv(DnnBase, COp):
or
desc
.
type
.
ctype
!=
'cudnnConvolutionDescriptor_t'
:
raise
TypeError
(
'desc must be cudnnConvolutionDescriptor_t'
)
alpha
=
ensure_d
ouble
(
alpha
,
_one
,
'alpha'
)
beta
=
ensure_d
ouble
(
beta
,
_zero
,
'beta'
)
alpha
=
ensure_d
t
(
alpha
,
_one
,
'alpha'
,
img
.
dtype
)
beta
=
ensure_d
t
(
beta
,
_zero
,
'beta'
,
img
.
dtype
)
return
Apply
(
self
,
[
img
,
kern
,
output
,
desc
,
alpha
,
beta
],
[
output
.
type
()])
...
...
@@ -577,8 +577,8 @@ class GpuDnnConvGradW(DnnBase, COp):
or
desc
.
type
.
ctype
!=
'cudnnConvolutionDescriptor_t'
:
raise
TypeError
(
'desc must be cudnnConvolutionDescriptor_t'
)
alpha
=
ensure_d
ouble
(
alpha
,
_one
,
'alpha'
)
beta
=
ensure_d
ouble
(
beta
,
_zero
,
'beta'
)
alpha
=
ensure_d
t
(
alpha
,
_one
,
'alpha'
,
img
.
dtype
)
beta
=
ensure_d
t
(
beta
,
_zero
,
'beta'
,
img
.
dtype
)
return
Apply
(
self
,
[
img
,
topgrad
,
output
,
desc
,
alpha
,
beta
],
[
output
.
type
()])
...
...
@@ -644,8 +644,8 @@ class GpuDnnConvGradI(DnnBase):
or
desc
.
type
.
ctype
!=
'cudnnConvolutionDescriptor_t'
:
raise
TypeError
(
'desc must be cudnnConvolutionDescriptor_t'
)
alpha
=
ensure_d
ouble
(
alpha
,
_one
,
'alpha'
)
beta
=
ensure_d
ouble
(
beta
,
_zero
,
'beta'
)
alpha
=
ensure_d
t
(
alpha
,
_one
,
'alpha'
,
kern
.
dtype
)
beta
=
ensure_d
t
(
beta
,
_zero
,
'beta'
,
kern
.
dtype
)
return
Apply
(
self
,
[
kern
,
topgrad
,
output
,
desc
,
alpha
,
beta
],
[
output
.
type
()])
...
...
theano/sandbox/gpuarray/opt_util.py
浏览文件 @
14e3a1e8
...
...
@@ -7,10 +7,10 @@ from theano.gof import local_optimizer
from
theano.tensor
import
(
DimShuffle
,
get_scalar_constant_value
,
NotScalarConstantError
)
from
.basic_ops
import
GpuFromHost
,
HostFromGpu
,
host_from_gpu
from
.basic_ops
import
GpuFromHost
,
HostFromGpu
from
.elemwise
import
GpuDimShuffle
,
GpuElemwise
_one
=
scal
.
constant
(
numpy
.
asarray
(
1.0
,
dtype
=
'float
32
'
))
_one
=
scal
.
constant
(
numpy
.
asarray
(
1.0
,
dtype
=
'float
64
'
))
def
grab_cpu_scalar
(
v
,
nd
):
...
...
@@ -18,10 +18,10 @@ def grab_cpu_scalar(v, nd):
n
=
v
.
owner
if
(
isinstance
(
n
.
op
,
GpuDimShuffle
)
and
n
.
op
.
new_order
==
(
'x'
,)
*
nd
):
return
host_from_gpu
(
n
.
inputs
[
0
])
return
grab_cpu_scalar
(
n
.
inputs
[
0
])
elif
(
isinstance
(
n
.
op
,
DimShuffle
)
and
n
.
op
.
new_order
==
(
'x'
,)
*
nd
):
return
n
.
inputs
[
0
]
return
grab_cpu_scalar
(
n
.
inputs
[
0
])
elif
isinstance
(
n
.
op
,
GpuFromHost
):
return
grab_cpu_scalar
(
n
.
inputs
[
0
],
nd
=
nd
)
else
:
...
...
@@ -37,7 +37,7 @@ def find_node(v, cls, ignore_clients=False):
# that has the op class specified. If ignore_clients is False (the
# default) it will only dig through nodes that have a single
# client.
if
v
.
owner
is
not
None
and
(
ignore_clients
or
v
.
clients
==
1
):
if
v
.
owner
is
not
None
and
(
ignore_clients
or
len
(
v
.
clients
)
==
1
):
if
isinstance
(
v
.
owner
.
op
,
cls
):
return
v
.
owner
elif
(
isinstance
(
v
.
owner
.
op
,
GpuFromHost
)
and
...
...
theano/tensor/basic.py
浏览文件 @
14e3a1e8
...
...
@@ -593,7 +593,7 @@ def get_scalar_constant_value(orig_v, elemwise=True,
# mess with the stabilization optimization and be too slow.
# We put all the scalar Ops used by get_canonical_form_slice()
# to allow it to determine the broadcast pattern correctly.
elif
isinstance
(
v
.
owner
.
op
,
ScalarFromTensor
):
elif
isinstance
(
v
.
owner
.
op
,
(
ScalarFromTensor
,
TensorFromScalar
)
):
return
get_scalar_constant_value
(
v
.
owner
.
inputs
[
0
])
elif
isinstance
(
v
.
owner
.
op
,
scal
.
ScalarOp
):
if
isinstance
(
v
.
owner
.
op
,
scal
.
Second
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论