Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c8bc4549
提交
c8bc4549
authored
10月 05, 2015
作者:
AdeB
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Force the user to specify both n_classes and n_outputs_per_class in the h_softmax
上级
cb59e785
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
24 行删除
+11
-24
nnet.py
theano/tensor/nnet/nnet.py
+11
-24
没有找到文件。
theano/tensor/nnet/nnet.py
浏览文件 @
c8bc4549
...
@@ -2053,7 +2053,7 @@ def relu(x, alpha=0):
...
@@ -2053,7 +2053,7 @@ def relu(x, alpha=0):
def
h_softmax
(
x
,
batch_size
,
n_outputs
,
W1
,
b1
,
W2
,
b2
,
def
h_softmax
(
x
,
batch_size
,
n_outputs
,
W1
,
b1
,
W2
,
b2
,
n_classes
=
None
,
n_outputs_per_class
=
None
,
target
=
None
):
n_classes
,
n_outputs_per_class
,
target
=
None
):
""" Two-level hierarchical softmax.
""" Two-level hierarchical softmax.
Outputs are grouped in sqrt(n_outputs) classes.
Outputs are grouped in sqrt(n_outputs) classes.
...
@@ -2081,15 +2081,12 @@ def h_softmax(x, batch_size, n_outputs, W1, b1, W2, b2,
...
@@ -2081,15 +2081,12 @@ def h_softmax(x, batch_size, n_outputs, W1, b1, W2, b2,
the number of outputs.
the number of outputs.
n_classes: int
n_classes: int
(optional, default None)
the number of classes of the two-layer hierarchical softmax. It
the number of classes of the two-layer hierarchical softmax. It
corresponds to the number of outputs of the first softmax.
It can be
corresponds to the number of outputs of the first softmax.
See note at
set to None, see the note at the end of the docstring
.
the end
.
n_outputs_per_class: int
n_outputs_per_class: int
(optional, default None)
the number of outputs per class. See note at the end.
the number of outputs per class. It can be set to None, see the note
at the end of the docstring.
W1: tensor of shape (number of features of the input x, number of classes)
W1: tensor of shape (number of features of the input x, number of classes)
the weight matrix of the first softmax, which maps the input x to the
the weight matrix of the first softmax, which maps the input x to the
...
@@ -2115,25 +2112,15 @@ def h_softmax(x, batch_size, n_outputs, W1, b1, W2, b2,
...
@@ -2115,25 +2112,15 @@ def h_softmax(x, batch_size, n_outputs, W1, b1, W2, b2,
Notes
Notes
-----
-----
n_outputs_per_class and n_classes do not need to be defined. If
The product of n_outputs_per_class and n_classes has to be greater or equal
both are not defined, then they are set to the square root of the
to n_outputs. If it is strictly greater, then the irrelevant outputs will
number of outputs, which is the most computational efficient
be ignored.
configuration. If only one is defined, the other is inferred so that
n_outputs_per_class and n_classes have to be the same as the corresponding
their product equals the number of outputs n_outputs (more precisely it is
dimensions of the tensors of W1, b1, W2 and b2.
the smallest integer such that their product is greater or equal to
The most computational efficient configuration is when n_outputs_per_class
n_outputs).
and n_classes are equal to the square root of n_outputs.
"""
"""
# In case one or both of n_outputs_per_class and n_classes are not defined
if
not
n_outputs_per_class
and
not
n_classes
:
n_outputs_per_class
=
numpy
.
ceil
(
numpy
.
sqrt
(
n_outputs
))
n_classes
=
numpy
.
ceil
(
n_outputs
/
n_outputs_per_class
)
elif
n_outputs_per_class
and
not
n_classes
:
n_classes
=
numpy
.
ceil
(
n_outputs
/
n_outputs_per_class
)
elif
n_classes
and
not
n_outputs_per_class
:
n_outputs_per_class
=
numpy
.
ceil
(
n_outputs
/
n_classes
)
# First softmax that computes the probabilities of belonging to each class
# First softmax that computes the probabilities of belonging to each class
class_probs
=
theano
.
tensor
.
nnet
.
softmax
(
tensor
.
dot
(
x
,
W1
)
+
b1
)
class_probs
=
theano
.
tensor
.
nnet
.
softmax
(
tensor
.
dot
(
x
,
W1
)
+
b1
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论