Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4f291961
提交
4f291961
authored
11月 09, 2016
作者:
Gijs van Tulder
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename some stdinv to invstd.
上级
51a2a510
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
15 行增加
和
15 行删除
+15
-15
dnn.py
theano/gpuarray/dnn.py
+3
-3
dnn.py
theano/sandbox/cuda/dnn.py
+3
-3
bn.py
theano/tensor/nnet/bn.py
+9
-9
没有找到文件。
theano/gpuarray/dnn.py
浏览文件 @
4f291961
...
@@ -2432,7 +2432,7 @@ def dnn_batch_normalization_train(inputs, gamma, beta, mode='per-activation',
...
@@ -2432,7 +2432,7 @@ def dnn_batch_normalization_train(inputs, gamma, beta, mode='per-activation',
Batch-normalized inputs.
Batch-normalized inputs.
mean : tensor
mean : tensor
Means of `inputs` across the normalization axes.
Means of `inputs` across the normalization axes.
stdinv
: tensor
invstd
: tensor
Inverse standard deviations of `inputs` across the normalization axes.
Inverse standard deviations of `inputs` across the normalization axes.
Notes
Notes
...
@@ -2445,8 +2445,8 @@ def dnn_batch_normalization_train(inputs, gamma, beta, mode='per-activation',
...
@@ -2445,8 +2445,8 @@ def dnn_batch_normalization_train(inputs, gamma, beta, mode='per-activation',
axes = 0 if mode == 'per-activation' else (0, 2, 3)
axes = 0 if mode == 'per-activation' else (0, 2, 3)
mean = inputs.mean(axes, keepdims=True)
mean = inputs.mean(axes, keepdims=True)
stdinv
= T.inv(T.sqrt(inputs.var(axes, keepdims=True) + epsilon))
invstd
= T.inv(T.sqrt(inputs.var(axes, keepdims=True) + epsilon))
out = (inputs - mean) * gamma *
stdinv
+ beta
out = (inputs - mean) * gamma *
invstd
+ beta
For 5d tensors, the axes are (0, 2, 3, 4).
For 5d tensors, the axes are (0, 2, 3, 4).
"""
"""
...
...
theano/sandbox/cuda/dnn.py
浏览文件 @
4f291961
...
@@ -2749,7 +2749,7 @@ def dnn_batch_normalization_train(inputs, gamma, beta, mode='per-activation',
...
@@ -2749,7 +2749,7 @@ def dnn_batch_normalization_train(inputs, gamma, beta, mode='per-activation',
Batch-normalized inputs.
Batch-normalized inputs.
mean : tensor
mean : tensor
Means of `inputs` across the normalization axes.
Means of `inputs` across the normalization axes.
stdinv
: tensor
invstd
: tensor
Inverse standard deviations of `inputs` across the normalization axes.
Inverse standard deviations of `inputs` across the normalization axes.
Notes
Notes
...
@@ -2762,8 +2762,8 @@ def dnn_batch_normalization_train(inputs, gamma, beta, mode='per-activation',
...
@@ -2762,8 +2762,8 @@ def dnn_batch_normalization_train(inputs, gamma, beta, mode='per-activation',
axes = 0 if mode == 'per-activation' else (0, 2, 3)
axes = 0 if mode == 'per-activation' else (0, 2, 3)
mean = inputs.mean(axes, keepdims=True)
mean = inputs.mean(axes, keepdims=True)
stdinv
= T.inv(T.sqrt(inputs.var(axes, keepdims=True) + epsilon))
invstd
= T.inv(T.sqrt(inputs.var(axes, keepdims=True) + epsilon))
out = (inputs - mean) * gamma *
stdinv
+ beta
out = (inputs - mean) * gamma *
invstd
+ beta
For 5d tensors, the axes are (0, 2, 3, 4).
For 5d tensors, the axes are (0, 2, 3, 4).
"""
"""
...
...
theano/tensor/nnet/bn.py
浏览文件 @
4f291961
...
@@ -114,7 +114,7 @@ def batch_normalization_train(inputs, gamma, beta, axes='per-activation',
...
@@ -114,7 +114,7 @@ def batch_normalization_train(inputs, gamma, beta, axes='per-activation',
Batch-normalized inputs.
Batch-normalized inputs.
mean : tensor
mean : tensor
Means of `inputs` across the normalization axes.
Means of `inputs` across the normalization axes.
stdinv
: tensor
invstd
: tensor
Inverse standard deviations of `inputs` across the normalization axes.
Inverse standard deviations of `inputs` across the normalization axes.
Notes
Notes
...
@@ -131,8 +131,8 @@ def batch_normalization_train(inputs, gamma, beta, axes='per-activation',
...
@@ -131,8 +131,8 @@ def batch_normalization_train(inputs, gamma, beta, axes='per-activation',
# for spatial normalization
# for spatial normalization
axes = (0,) + tuple(range(2, inputs.ndim))
axes = (0,) + tuple(range(2, inputs.ndim))
mean = inputs.mean(axes, keepdims=True)
mean = inputs.mean(axes, keepdims=True)
stdinv
= T.inv(T.sqrt(inputs.var(axes, keepdims=True) + epsilon))
invstd
= T.inv(T.sqrt(inputs.var(axes, keepdims=True) + epsilon))
out = (inputs - mean) * gamma *
stdinv
+ beta
out = (inputs - mean) * gamma *
invstd
+ beta
"""
"""
ndim
=
inputs
.
ndim
ndim
=
inputs
.
ndim
if
gamma
.
ndim
!=
ndim
or
beta
.
ndim
!=
ndim
:
if
gamma
.
ndim
!=
ndim
or
beta
.
ndim
!=
ndim
:
...
@@ -315,12 +315,12 @@ class AbstractBatchNormTrain(Op):
...
@@ -315,12 +315,12 @@ class AbstractBatchNormTrain(Op):
raise
ValueError
(
'axes should be less than ndim (<
%
d), but
%
s given'
%
(
x
.
ndim
,
str
(
axes
)))
raise
ValueError
(
'axes should be less than ndim (<
%
d), but
%
s given'
%
(
x
.
ndim
,
str
(
axes
)))
mean
=
x
.
mean
(
axes
,
keepdims
=
True
)
mean
=
x
.
mean
(
axes
,
keepdims
=
True
)
stdinv
=
1.0
/
numpy
.
sqrt
(
x
.
var
(
axes
,
keepdims
=
True
)
+
epsilon
)
invstd
=
1.0
/
numpy
.
sqrt
(
x
.
var
(
axes
,
keepdims
=
True
)
+
epsilon
)
out
=
(
x
-
mean
)
*
(
scale
*
stdinv
)
+
bias
out
=
(
x
-
mean
)
*
(
scale
*
invstd
)
+
bias
output_storage
[
0
][
0
]
=
out
output_storage
[
0
][
0
]
=
out
output_storage
[
1
][
0
]
=
mean
output_storage
[
1
][
0
]
=
mean
output_storage
[
2
][
0
]
=
stdinv
output_storage
[
2
][
0
]
=
invstd
class
AbstractBatchNormInference
(
Op
):
class
AbstractBatchNormInference
(
Op
):
...
@@ -440,10 +440,10 @@ def local_abstract_batch_norm_train(node):
...
@@ -440,10 +440,10 @@ def local_abstract_batch_norm_train(node):
return
None
return
None
mean
=
x
.
mean
(
axes
,
keepdims
=
True
)
mean
=
x
.
mean
(
axes
,
keepdims
=
True
)
stdinv
=
T
.
inv
(
T
.
sqrt
(
x
.
var
(
axes
,
keepdims
=
True
)
+
epsilon
))
invstd
=
T
.
inv
(
T
.
sqrt
(
x
.
var
(
axes
,
keepdims
=
True
)
+
epsilon
))
out
=
(
x
-
mean
)
*
(
scale
*
stdinv
)
+
bias
out
=
(
x
-
mean
)
*
(
scale
*
invstd
)
+
bias
# TODO copy_stack_trace?
# TODO copy_stack_trace?
return
[
out
,
mean
,
stdinv
]
return
[
out
,
mean
,
invstd
]
@local_optimizer
([
AbstractBatchNormTrainGrad
])
@local_optimizer
([
AbstractBatchNormTrainGrad
])
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论