Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a5b73b01
提交
a5b73b01
authored
6月 18, 2017
作者:
vipulraheja
提交者:
Arnaud Bergeron
7月 20, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add selu activation
上级
e1911566
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
38 行增加
和
1 行删除
+38
-1
__init__.py
theano/tensor/nnet/__init__.py
+1
-1
nnet.py
theano/tensor/nnet/nnet.py
+23
-0
test_nnet.py
theano/tensor/nnet/tests/test_nnet.py
+14
-0
没有找到文件。
theano/tensor/nnet/__init__.py
浏览文件 @
a5b73b01
...
@@ -18,7 +18,7 @@ from .nnet import (
...
@@ -18,7 +18,7 @@ from .nnet import (
graph_merge_softmax_with_crossentropy_softmax
,
h_softmax
,
graph_merge_softmax_with_crossentropy_softmax
,
h_softmax
,
logsoftmax
,
logsoftmax_op
,
prepend_0_to_each_row
,
prepend_1_to_each_row
,
logsoftmax
,
logsoftmax_op
,
prepend_0_to_each_row
,
prepend_1_to_each_row
,
prepend_scalar_to_each_row
,
relu
,
softmax
,
softmax_grad
,
softmax_graph
,
prepend_scalar_to_each_row
,
relu
,
softmax
,
softmax_grad
,
softmax_graph
,
softmax_op
,
softmax_simplifier
,
softmax_with_bias
,
elu
,
softmax_op
,
softmax_simplifier
,
softmax_with_bias
,
elu
,
selu
,
confusion_matrix
,
softsign
)
confusion_matrix
,
softsign
)
from
.
import
opt
from
.
import
opt
from
.conv
import
ConvOp
from
.conv
import
ConvOp
...
...
theano/tensor/nnet/nnet.py
浏览文件 @
a5b73b01
...
@@ -2448,6 +2448,29 @@ def elu(x, alpha=1):
...
@@ -2448,6 +2448,29 @@ def elu(x, alpha=1):
return
tensor
.
switch
(
x
>
0
,
x
,
alpha
*
tensor
.
expm1
(
x
))
return
tensor
.
switch
(
x
>
0
,
x
,
alpha
*
tensor
.
expm1
(
x
))
def
selu
(
x
,
alpha
=
1
):
"""Compute the element-wise Scaled Exponential Linear unit.
Parameters
----------
x : symbolic tensor
Tensor to compute the activation function for.
Returns
-------
symbolic tensor
Element-wise scaled exponential linear activation function applied to `x`.
References
----------
.. [1] Klambauer, Gunter, et al.
"Self-Normalizing Neural Networks" <https://arxiv.org/abs/1706.02515>
"""
alpha
=
1.6732632423543772848170429916717
scale
=
1.0507009873554804934193349852946
return
scale
*
elu
(
x
,
alpha
)
class
ScalarSoftsign
(
theano
.
scalar
.
UnaryScalarOp
):
class
ScalarSoftsign
(
theano
.
scalar
.
UnaryScalarOp
):
"""
"""
Softsign activation function
Softsign activation function
...
...
theano/tensor/nnet/tests/test_nnet.py
浏览文件 @
a5b73b01
...
@@ -32,6 +32,7 @@ from theano.tensor.nnet import (categorical_crossentropy,
...
@@ -32,6 +32,7 @@ from theano.tensor.nnet import (categorical_crossentropy,
relu
,
relu
,
h_softmax
,
h_softmax
,
elu
,
elu
,
selu
,
binary_crossentropy
,
binary_crossentropy
,
sigmoid_binary_crossentropy
,
sigmoid_binary_crossentropy
,
confusion_matrix
)
confusion_matrix
)
...
@@ -1737,6 +1738,19 @@ def test_elu():
...
@@ -1737,6 +1738,19 @@ def test_elu():
utt
.
assert_allclose
(
y
,
np
.
where
(
X
>
0
,
X
,
alpha
*
(
np
.
exp
(
X
)
-
1
)))
utt
.
assert_allclose
(
y
,
np
.
where
(
X
>
0
,
X
,
alpha
*
(
np
.
exp
(
X
)
-
1
)))
def
test_selu
():
alpha
=
1.6732632423543772848170429916717
scale
=
1.0507009873554804934193349852946
x
=
matrix
(
'x'
)
seed
=
theano
.
tests
.
unittest_tools
.
fetch_seed
()
rng
=
np
.
random
.
RandomState
(
seed
)
X
=
rng
.
randn
(
20
,
30
)
.
astype
(
config
.
floatX
)
y
=
selu
(
x
)
.
eval
({
x
:
X
})
utt
.
assert_allclose
(
y
,
np
.
where
(
X
>
0
,
scale
*
X
,
scale
*
alpha
*
(
np
.
exp
(
X
)
-
1
)))
def
test_binary_crossentropy_reshape
():
def
test_binary_crossentropy_reshape
():
# Reported as https://github.com/Theano/Theano/issues/4086
# Reported as https://github.com/Theano/Theano/issues/4086
a
=
tensor
.
tensor4
(
'a'
)
a
=
tensor
.
tensor4
(
'a'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论