Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f669bd8e
提交
f669bd8e
authored
7月 25, 2017
作者:
João Victor Risso
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename grid_dims to out_dims in spatial transformer ops
Signed-off-by:
João Victor Risso
<
joaovictor.risso@gmail.com
>
上级
eaa12937
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
17 行增加
和
17 行删除
+17
-17
dnn.py
theano/gpuarray/dnn.py
+17
-17
没有找到文件。
theano/gpuarray/dnn.py
浏览文件 @
f669bd8e
...
@@ -2772,13 +2772,13 @@ class GpuDnnTransformerDesc(COp):
...
@@ -2772,13 +2772,13 @@ class GpuDnnTransformerDesc(COp):
assert
cudnn
.
cudnnDataType_t
.
has_alias
(
precision
)
assert
cudnn
.
cudnnDataType_t
.
has_alias
(
precision
)
self
.
precision
=
precision
self
.
precision
=
precision
def
make_node
(
self
,
dimension
s
):
def
make_node
(
self
,
out_dim
s
):
dimensions
=
as_tensor_variable
(
dimension
s
)
out_dims
=
as_tensor_variable
(
out_dim
s
)
assert
dimension
s
.
dtype
in
theano
.
tensor
.
basic
.
integer_dtypes
assert
out_dim
s
.
dtype
in
theano
.
tensor
.
basic
.
integer_dtypes
assert
dimension
s
.
ndim
==
1
assert
out_dim
s
.
ndim
==
1
dimensions
=
theano
.
tensor
.
basic
.
cast
(
dimension
s
,
'int64'
)
out_dims
=
theano
.
tensor
.
basic
.
cast
(
out_dim
s
,
'int64'
)
node
=
Apply
(
self
,
[
dimension
s
],
node
=
Apply
(
self
,
[
out_dim
s
],
[
CDataType
(
"cudnnSpatialTransformerDescriptor_t"
,
[
CDataType
(
"cudnnSpatialTransformerDescriptor_t"
,
freefunc
=
"cudnnDestroySpatialTransformerDescriptor"
)()])
freefunc
=
"cudnnDestroySpatialTransformerDescriptor"
)()])
# DebugMode cannot compare the values of CDataType variables, so by
# DebugMode cannot compare the values of CDataType variables, so by
...
@@ -2814,26 +2814,26 @@ class GpuDnnTransformerGrid(DnnBase):
...
@@ -2814,26 +2814,26 @@ class GpuDnnTransformerGrid(DnnBase):
assert
theta
.
dtype
in
(
'float16'
,
'float32'
,
'float64'
)
assert
theta
.
dtype
in
(
'float16'
,
'float32'
,
'float64'
)
assert
theta
.
ndim
==
3
assert
theta
.
ndim
==
3
# Setup
grid
dimensions using input from descriptor
# Setup
output
dimensions using input from descriptor
grid
_dims
=
as_tensor_variable
(
desc
.
owner
.
inputs
[
0
])
out
_dims
=
as_tensor_variable
(
desc
.
owner
.
inputs
[
0
])
assert
grid
_dims
.
dtype
in
theano
.
tensor
.
basic
.
integer_dtypes
assert
out
_dims
.
dtype
in
theano
.
tensor
.
basic
.
integer_dtypes
assert
grid
_dims
.
ndim
==
1
assert
out
_dims
.
ndim
==
1
# Ensure 64-bit ints are passed to the C code
# Ensure 64-bit ints are passed to the C code
grid_dims
=
theano
.
tensor
.
basic
.
cast
(
grid
_dims
,
'int64'
)
out_dims
=
theano
.
tensor
.
basic
.
cast
(
out
_dims
,
'int64'
)
grid
=
GpuArrayType
(
dtype
=
theta
.
dtype
,
grid
=
GpuArrayType
(
dtype
=
theta
.
dtype
,
broadcastable
=
(
theta
.
type
.
ndim
+
1
)
*
(
False
,),
broadcastable
=
(
theta
.
type
.
ndim
+
1
)
*
(
False
,),
context_name
=
context_name
)()
context_name
=
context_name
)()
inputs
=
[
theta
,
grid
_dims
,
desc
]
inputs
=
[
theta
,
out
_dims
,
desc
]
outputs
=
[
grid
]
outputs
=
[
grid
]
return
Apply
(
self
,
inputs
,
outputs
)
return
Apply
(
self
,
inputs
,
outputs
)
def
grad
(
self
,
inputs
,
grads
):
def
grad
(
self
,
inputs
,
grads
):
theta
,
grid
_dims
,
desc
=
inputs
theta
,
out
_dims
,
desc
=
inputs
dgrid
=
grads
[
0
]
dgrid
=
grads
[
0
]
dtheta
=
GpuDnnTransformerGradT
()(
dgrid
,
desc
)
dtheta
=
GpuDnnTransformerGradT
()(
dgrid
,
desc
)
return
[
dtheta
,
grad_not_implemented
(
self
,
1
,
grid
_dims
),
DisconnectedType
()()]
return
[
dtheta
,
grad_not_implemented
(
self
,
1
,
out
_dims
),
DisconnectedType
()()]
def
connection_pattern
(
self
,
node
):
def
connection_pattern
(
self
,
node
):
# not connected to desc
# not connected to desc
...
@@ -3005,13 +3005,13 @@ def dnn_spatialtf(img, theta, scale_width=1, scale_height=1, precision=theano.co
...
@@ -3005,13 +3005,13 @@ def dnn_spatialtf(img, theta, scale_width=1, scale_height=1, precision=theano.co
Also, the only grid sampler method available is the bilinear interpolation.
Also, the only grid sampler method available is the bilinear interpolation.
"""
"""
grid
_dims
=
(
img
.
shape
[
0
],
img
.
shape
[
1
],
out
_dims
=
(
img
.
shape
[
0
],
img
.
shape
[
1
],
img
.
shape
[
2
]
*
scale_height
,
img
.
shape
[
2
]
*
scale_height
,
img
.
shape
[
3
]
*
scale_width
)
img
.
shape
[
3
]
*
scale_width
)
grid_dims
=
tuple
([
as_scalar
(
v
)
.
astype
(
'int32'
)
for
v
in
grid
_dims
])
out_dims
=
tuple
([
as_scalar
(
v
)
.
astype
(
'int64'
)
for
v
in
out
_dims
])
# Create spatial transformer descriptor
# Create spatial transformer descriptor
desc
=
GpuDnnTransformerDesc
(
precision
)(
grid
_dims
)
desc
=
GpuDnnTransformerDesc
(
precision
)(
out
_dims
)
context_name
=
infer_context_name
(
desc
)
context_name
=
infer_context_name
(
desc
)
img
=
gpu_contiguous
(
as_gpuarray_variable
(
img
,
context_name
))
img
=
gpu_contiguous
(
as_gpuarray_variable
(
img
,
context_name
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论