Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
18e5ee92
提交
18e5ee92
authored
5月 09, 2016
作者:
abergeron
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4484 from nouiz/relu
Relu
上级
beefa939
b26239a9
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
28 行增加
和
1 行删除
+28
-1
basic.txt
doc/library/tensor/basic.txt
+14
-0
setup.py
setup.py
+1
-1
nnet.py
theano/tensor/nnet/nnet.py
+4
-0
test_nnet.py
theano/tensor/nnet/tests/test_nnet.py
+9
-0
没有找到文件。
doc/library/tensor/basic.txt
浏览文件 @
18e5ee92
...
@@ -676,6 +676,20 @@ Creating Tensor
...
@@ -676,6 +676,20 @@ Creating Tensor
Returns a tensor filled with 1s that has same shape as `x`.
Returns a tensor filled with 1s that has same shape as `x`.
.. function:: zeros(shape, dtype=None)
:param shape: a tuple/list of scalar with the shape information.
:param dtype: the dtype of the new tensor. If None, will use floatX.
Returns a tensor filled with 0s of the provided shape.
.. function:: ones(shape, dtype=None)
:param shape: a tuple/list of scalar with the shape information.
:param dtype: the dtype of the new tensor. If None, will use floatX.
Returns a tensor filled with 1s of the provided shape.
.. function:: fill(a,b)
.. function:: fill(a,b)
:param a: tensor that has same shape as output
:param a: tensor that has same shape as output
...
...
setup.py
浏览文件 @
18e5ee92
...
@@ -54,7 +54,7 @@ PLATFORMS = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"]
...
@@ -54,7 +54,7 @@ PLATFORMS = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"]
MAJOR
=
0
MAJOR
=
0
MINOR
=
9
MINOR
=
9
MICRO
=
0
MICRO
=
0
SUFFIX
=
"dev
0
"
# Should be blank except for rc's, betas, etc.
SUFFIX
=
"dev
1
"
# Should be blank except for rc's, betas, etc.
ISRELEASED
=
False
ISRELEASED
=
False
VERSION
=
'
%
d.
%
d.
%
d
%
s'
%
(
MAJOR
,
MINOR
,
MICRO
,
SUFFIX
)
VERSION
=
'
%
d.
%
d.
%
d
%
s'
%
(
MAJOR
,
MINOR
,
MICRO
,
SUFFIX
)
...
...
theano/tensor/nnet/nnet.py
浏览文件 @
18e5ee92
...
@@ -2220,6 +2220,10 @@ def relu(x, alpha=0):
...
@@ -2220,6 +2220,10 @@ def relu(x, alpha=0):
if
alpha
==
0
:
if
alpha
==
0
:
return
0.5
*
(
x
+
abs
(
x
))
return
0.5
*
(
x
+
abs
(
x
))
else
:
else
:
# We can't use 0.5 and 1 for one and half. as if alpha is a
# numpy dtype, they will be considered as float64, so would
# cause upcast to float64.
alpha
=
tensor
.
as_tensor_variable
(
alpha
)
f1
=
0.5
*
(
1
+
alpha
)
f1
=
0.5
*
(
1
+
alpha
)
f2
=
0.5
*
(
1
-
alpha
)
f2
=
0.5
*
(
1
-
alpha
)
return
f1
*
x
+
f2
*
abs
(
x
)
return
f1
*
x
+
f2
*
abs
(
x
)
...
...
theano/tensor/nnet/tests/test_nnet.py
浏览文件 @
18e5ee92
...
@@ -1598,6 +1598,15 @@ def test_relu():
...
@@ -1598,6 +1598,15 @@ def test_relu():
y
=
relu
(
x
,
alpha
)
.
eval
({
x
:
X
,
alpha
:
A
})
y
=
relu
(
x
,
alpha
)
.
eval
({
x
:
X
,
alpha
:
A
})
assert
numpy
.
allclose
(
y
,
numpy
.
where
(
X
>
0
,
X
,
A
*
X
),
rtol
=
3e-5
)
assert
numpy
.
allclose
(
y
,
numpy
.
where
(
X
>
0
,
X
,
A
*
X
),
rtol
=
3e-5
)
# test that for alpha of ndarray don't cause upcast.
x
=
matrix
(
'x'
,
dtype
=
'float32'
)
rng
=
numpy
.
random
.
RandomState
(
seed
)
X
=
rng
.
randn
(
20
,
30
)
.
astype
(
'float32'
)
alpha
=
numpy
.
asarray
(
.
123
,
dtype
=
'float32'
)
y
=
relu
(
x
,
alpha
)
.
eval
({
x
:
X
})
assert
numpy
.
allclose
(
y
,
numpy
.
where
(
X
>
0
,
X
,
alpha
*
X
))
assert
y
.
dtype
==
'float32'
def
test_h_softmax
():
def
test_h_softmax
():
"""
"""
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论