Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ab028336
提交
ab028336
authored
2月 02, 2017
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Force tensor variable in the make node.
上级
77417690
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
23 行增加
和
8 行删除
+23
-8
bn.py
theano/tensor/nnet/bn.py
+23
-8
没有找到文件。
theano/tensor/nnet/bn.py
浏览文件 @
ab028336
...
@@ -413,15 +413,20 @@ class AbstractBatchNormTrain(Op):
...
@@ -413,15 +413,20 @@ class AbstractBatchNormTrain(Op):
def
make_node
(
self
,
x
,
scale
,
bias
,
epsilon
=
1e-4
,
def
make_node
(
self
,
x
,
scale
,
bias
,
epsilon
=
1e-4
,
running_average_factor
=
0.1
,
running_average_factor
=
0.1
,
running_mean
=
None
,
running_var
=
None
):
running_mean
=
None
,
running_var
=
None
):
x
=
as_tensor_variable
(
x
)
scale
=
as_tensor_variable
(
scale
)
bias
=
as_tensor_variable
(
bias
)
epsilon
=
as_tensor_variable
(
epsilon
)
running_average_factor
=
as_tensor_variable
(
running_average_factor
)
if
running_mean
is
not
None
:
running_mean
=
as_tensor_variable
(
running_mean
)
if
running_var
is
not
None
:
running_var
=
as_tensor_variable
(
running_var
)
assert
x
.
ndim
==
scale
.
ndim
==
bias
.
ndim
assert
x
.
ndim
==
scale
.
ndim
==
bias
.
ndim
assert
((
running_mean
is
None
and
running_var
is
None
)
or
assert
((
running_mean
is
None
and
running_var
is
None
)
or
(
running_mean
is
not
None
and
running_var
is
not
None
))
(
running_mean
is
not
None
and
running_var
is
not
None
))
assert
(
running_mean
is
None
or
running_mean
.
ndim
==
x
.
ndim
)
assert
(
running_mean
is
None
or
running_mean
.
ndim
==
x
.
ndim
)
assert
(
running_var
is
None
or
running_var
.
ndim
==
x
.
ndim
)
assert
(
running_var
is
None
or
running_var
.
ndim
==
x
.
ndim
)
if
not
isinstance
(
epsilon
,
theano
.
Variable
):
epsilon
=
as_tensor_variable
(
epsilon
)
if
not
isinstance
(
running_average_factor
,
theano
.
Variable
):
running_average_factor
=
as_tensor_variable
(
running_average_factor
)
inputs
=
[
x
,
scale
,
bias
,
epsilon
,
running_average_factor
]
inputs
=
[
x
,
scale
,
bias
,
epsilon
,
running_average_factor
]
output_types
=
[
x
.
type
(),
scale
.
type
(),
scale
.
type
()]
output_types
=
[
x
.
type
(),
scale
.
type
(),
scale
.
type
()]
if
running_mean
is
not
None
and
running_var
is
not
None
:
if
running_mean
is
not
None
and
running_var
is
not
None
:
...
@@ -513,9 +518,14 @@ class AbstractBatchNormInference(Op):
...
@@ -513,9 +518,14 @@ class AbstractBatchNormInference(Op):
return
[
shape
[
0
]]
return
[
shape
[
0
]]
def
make_node
(
self
,
x
,
scale
,
bias
,
estimated_mean
,
estimated_variance
,
epsilon
=
1e-4
):
def
make_node
(
self
,
x
,
scale
,
bias
,
estimated_mean
,
estimated_variance
,
epsilon
=
1e-4
):
x
=
as_tensor_variable
(
x
)
scale
=
as_tensor_variable
(
scale
)
bias
=
as_tensor_variable
(
bias
)
estimated_mean
=
as_tensor_variable
(
estimated_mean
)
estimated_variance
=
as_tensor_variable
(
estimated_variance
)
epsilon
=
as_tensor_variable
(
epsilon
)
assert
x
.
ndim
==
scale
.
ndim
==
bias
.
ndim
==
estimated_mean
.
ndim
==
estimated_variance
.
ndim
assert
x
.
ndim
==
scale
.
ndim
==
bias
.
ndim
==
estimated_mean
.
ndim
==
estimated_variance
.
ndim
if
not
isinstance
(
epsilon
,
theano
.
Variable
):
epsilon
=
as_tensor_variable
(
epsilon
)
return
Apply
(
self
,
[
x
,
scale
,
bias
,
estimated_mean
,
estimated_variance
,
epsilon
],
[
x
.
type
()])
return
Apply
(
self
,
[
x
,
scale
,
bias
,
estimated_mean
,
estimated_variance
,
epsilon
],
[
x
.
type
()])
def
grad
(
self
,
inputs
,
grads
):
def
grad
(
self
,
inputs
,
grads
):
...
@@ -561,9 +571,14 @@ class AbstractBatchNormTrainGrad(Op):
...
@@ -561,9 +571,14 @@ class AbstractBatchNormTrainGrad(Op):
self
.
axes
=
axes
self
.
axes
=
axes
def
make_node
(
self
,
x
,
dy
,
scale
,
x_mean
,
x_invstd
,
epsilon
=
1e-4
):
def
make_node
(
self
,
x
,
dy
,
scale
,
x_mean
,
x_invstd
,
epsilon
=
1e-4
):
x
=
as_tensor_variable
(
x
)
dy
=
as_tensor_variable
(
dy
)
scale
=
as_tensor_variable
(
scale
)
x_mean
=
as_tensor_variable
(
x_mean
)
x_invstd
=
as_tensor_variable
(
x_invstd
)
epsilon
=
as_tensor_variable
(
epsilon
)
assert
x
.
ndim
==
dy
.
ndim
==
scale
.
ndim
==
x_mean
.
ndim
==
x_invstd
.
ndim
assert
x
.
ndim
==
dy
.
ndim
==
scale
.
ndim
==
x_mean
.
ndim
==
x_invstd
.
ndim
if
not
isinstance
(
epsilon
,
theano
.
Variable
):
epsilon
=
as_tensor_variable
(
epsilon
)
return
Apply
(
self
,
[
x
,
dy
,
scale
,
x_mean
,
x_invstd
,
epsilon
],
return
Apply
(
self
,
[
x
,
dy
,
scale
,
x_mean
,
x_invstd
,
epsilon
],
[
x
.
type
(),
scale
.
type
(),
scale
.
type
()])
[
x
.
type
(),
scale
.
type
(),
scale
.
type
()])
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论