Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
43a27b25
提交
43a27b25
authored
10月 16, 2015
作者:
AdeB
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reformat reference for h_softmax
上级
219d77b0
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
19 行增加
和
23 行删除
+19
-23
blocksparse.py
theano/sandbox/blocksparse.py
+11
-5
nnet.py
theano/tensor/nnet/nnet.py
+8
-13
test_nnet.py
theano/tensor/nnet/tests/test_nnet.py
+0
-4
test_flake8.py
theano/tests/test_flake8.py
+0
-1
没有找到文件。
theano/sandbox/blocksparse.py
浏览文件 @
43a27b25
from
__future__
import
print_function
import
sys
from
theano.tensor.nnet.blocksparse
import
*
import
warnings
from
theano.tensor.nnet.blocksparse
import
(
SparseBlockGemv
,
SparseBlockOuter
,
sparse_block_dot
,
sparse_block_gemv
,
sparse_block_gemv_inplace
,
sparse_block_outer
,
sparse_block_outer_inplace
)
print
(
"DEPRECATION: theano.sandbox.blocksparse does not exist anymore,"
"it has been moved to theano.tensor.nnet.blocksparse."
,
file
=
sys
.
stderr
)
__all__
=
[
SparseBlockGemv
,
SparseBlockOuter
,
sparse_block_dot
,
sparse_block_gemv
,
sparse_block_gemv_inplace
,
sparse_block_outer
,
sparse_block_outer_inplace
]
warnings
.
warn
(
"DEPRECATION: theano.sandbox.blocksparse does not exist anymore,"
"it has been moved to theano.tensor.nnet.blocksparse."
,
category
=
DeprecationWarning
)
theano/tensor/nnet/nnet.py
浏览文件 @
43a27b25
...
...
@@ -2059,8 +2059,7 @@ def h_softmax(x, batch_size, n_outputs, n_classes, n_outputs_per_class,
The architecture is composed of two softmax layers: the first predicts the
class of the input x while the second predicts the output of the input x in
the predicted class.
More explanations can be found in the original paper:
http://arxiv.org/abs/cs/0108006.
More explanations can be found in the original paper [1]_.
If target is specified, it will only compute the outputs of the
corresponding targets. Otherwise, if target is None, it will compute all
...
...
@@ -2074,35 +2073,26 @@ def h_softmax(x, batch_size, n_outputs, n_classes, n_outputs_per_class,
----------
x: tensor of shape (batch_size, number of features)
the minibatch input of the two-layer hierarchical softmax.
batch_size: int
the size of the minibatch input x.
n_outputs: int
the number of outputs.
n_classes: int
the number of classes of the two-layer hierarchical softmax. It
corresponds to the number of outputs of the first softmax. See note at
the end.
n_outputs_per_class: int
the number of outputs per class. See note at the end.
W1: tensor of shape (number of features of the input x, n_classes)
the weight matrix of the first softmax, which maps the input x to the
probabilities of the classes.
b1: tensor of shape (n_classes,)
the bias vector of the first softmax layer.
W2: tensor of shape (n_classes, number of features of the input x, n_outputs_per_class)
the weight matrix of the second softmax, which maps the input x to
the probabilities of the outputs.
b2: tensor of shape (n_classes, n_outputs_per_class)
the bias vector of the second softmax layer.
target: tensor of shape either (batch_size,) or (batch_size, 1)
(optional, default None)
contains the indices of the targets for the minibatch
...
...
@@ -2112,14 +2102,14 @@ def h_softmax(x, batch_size, n_outputs, n_classes, n_outputs_per_class,
Returns
-------
tensor of shape (batch_size, n_outputs) or (batch_size, 1)
output_probs:
tensor of shape (batch_size, n_outputs) or (batch_size, 1)
Output of the two-layer hierarchical softmax for input x. If target is
not specified (None), then all the outputs are computed and the
returned tensor has shape (batch_size, n_outputs). Otherwise, when
target is specified, only the corresponding outputs are computed and
the returned tensor has thus shape (batch_size, 1).
Notes
:
Notes
-----
The product of n_outputs_per_class and n_classes has to be greater or equal
to n_outputs. If it is strictly greater, then the irrelevant outputs will
...
...
@@ -2128,6 +2118,11 @@ def h_softmax(x, batch_size, n_outputs, n_classes, n_outputs_per_class,
dimensions of the tensors of W1, b1, W2 and b2.
The most computational efficient configuration is when n_outputs_per_class
and n_classes are equal to the square root of n_outputs.
References
----------
.. [1] J. Goodman, "Classes for Fast Maximum Entropy Training,"
ICASSP, 2001, <http://arxiv.org/abs/cs/0108006>`.
"""
# First softmax that computes the probabilities of belonging to each class
...
...
theano/tensor/nnet/tests/test_nnet.py
浏览文件 @
43a27b25
...
...
@@ -1510,6 +1510,3 @@ def test_h_softmax():
assert
(
fun_output_tg
(
x_mat
,
y_mat
)
.
shape
==
(
batch_size
,))
assert
(
fun_output
(
x_mat
)
.
shape
==
(
batch_size
,
output_size
))
if
__name__
==
'__main__'
:
unittest
.
main
()
\ No newline at end of file
theano/tests/test_flake8.py
浏览文件 @
43a27b25
...
...
@@ -104,7 +104,6 @@ whitelist_flake8 = [
"sandbox/theano_object.py"
,
"sandbox/scan.py"
,
"sandbox/symbolic_module.py"
,
"sandbox/blocksparse.py"
,
"sandbox/conv.py"
,
"sandbox/debug.py"
,
"sandbox/tests/test_theano_object.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论