Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ea902b07
提交
ea902b07
authored
10月 26, 2010
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove some errors printing from optimization with Softmax that are reverted by the env.
上级
dc84f81b
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
26 行增加
和
1 行删除
+26
-1
nnet.py
theano/tensor/nnet/nnet.py
+5
-1
test_nnet.py
theano/tensor/nnet/tests/test_nnet.py
+21
-0
没有找到文件。
theano/tensor/nnet/nnet.py
浏览文件 @
ea902b07
...
...
@@ -395,7 +395,11 @@ def local_softmax_with_bias(node):
except
:
#if our arguments have the wrong types, then forget about it
return
return
[
sm_bias
]
if
sm_bias
.
type
==
node
.
outputs
[
0
]
.
type
:
#This condition is not always true. See the test
#nnet/tests/test_nnet.py:T_SoftmaxWithBias.test_broadcast
return
[
sm_bias
]
def
softmax_simplifier
(
numerators
,
denominators
):
for
numerator
in
list
(
numerators
):
...
...
theano/tensor/nnet/tests/test_nnet.py
浏览文件 @
ea902b07
...
...
@@ -92,6 +92,27 @@ class T_SoftmaxWithBias(unittest.TestCase):
return
softmax_with_bias
(
a
,
b
)[:,
3
]
utt
.
verify_grad
(
f
,
[
numpy
.
random
.
rand
(
3
,
4
),
numpy
.
random
.
rand
(
4
)])
def
test_broadcast
(
self
):
#test that we don't raise an error during optimization for no good
#reason as softmax_with_bias don't support correctly some/all
#broadcasted inputs pattern
initial_W
=
numpy
.
asarray
(
[[
0.1
,
0.1
,
0.1
],
\
[
0.1
,
0.1
,
0.1
],
\
[
0.1
,
0.1
,
0.1
]],
\
dtype
=
theano
.
config
.
floatX
)
W
=
theano
.
shared
(
value
=
initial_W
,
name
=
'W'
)
vbias
=
theano
.
shared
(
value
=
0.1
,
name
=
'vbias'
)
#0.01
hid
=
T
.
vector
(
'hid'
)
f
=
theano
.
function
([
hid
],
T
.
nnet
.
softmax
(
T
.
dot
(
hid
,
W
.
T
)
+
vbias
))
ops
=
[
node
.
op
for
node
in
f
.
maker
.
env
.
toposort
()]
assert
softmax_with_bias
not
in
ops
assert
softmax
in
ops
print
f
([
0
,
1
,
0
])
print
f
.
maker
.
env
.
toposort
()
def
test_infer_shape
(
self
):
fff
=
theano
.
function
([],
outputs
=
softmax_with_bias
(
numpy
.
random
.
rand
(
3
,
4
),
numpy
.
random
.
rand
(
4
))
.
shape
)
assert
all
(
fff
()
==
[
3
,
4
])
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论