Skip to content

Commit a08dc83

Browse files
committed
remove arg 'non_leaf_num', test=develop
1 parent 7594787 commit a08dc83

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

paddle/fluid/API.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ paddle.fluid.layers.warpctc ArgSpec(args=['input', 'label', 'blank', 'norm_by_ti
9797
paddle.fluid.layers.sequence_reshape ArgSpec(args=['input', 'new_dim'], varargs=None, keywords=None, defaults=None)
9898
paddle.fluid.layers.transpose ArgSpec(args=['x', 'perm', 'name'], varargs=None, keywords=None, defaults=(None,))
9999
paddle.fluid.layers.im2sequence ArgSpec(args=['input', 'filter_size', 'stride', 'padding', 'input_image_size', 'out_stride', 'name'], varargs=None, keywords=None, defaults=(1, 1, 0, None, 1, None))
100-
paddle.fluid.layers.hsigmoid ArgSpec(args=['input', 'label', 'num_classes', 'param_attr', 'bias_attr', 'name', 'non_leaf_num', 'ptable', 'pcode', 'is_costum', 'is_sparse'], varargs=None, keywords=None, defaults=(None, None, None, None, None, None, None, False, False))
101100
paddle.fluid.layers.nce ArgSpec(args=['input', 'label', 'num_total_classes', 'sample_weight', 'param_attr', 'bias_attr', 'num_neg_samples', 'name', 'sampler', 'custom_dist', 'seed', 'is_sparse'], varargs=None, keywords=None, defaults=(None, None, None, None, None, 'uniform', None, 0, False))
101+
paddle.fluid.layers.hsigmoid ArgSpec(args=['input', 'label', 'num_classes', 'param_attr', 'bias_attr', 'name', 'path_table', 'path_code', 'is_custom', 'is_sparse'], varargs=None, keywords=None, defaults=(None, None, None, None, None, False, False))
102102
paddle.fluid.layers.beam_search ArgSpec(args=['pre_ids', 'pre_scores', 'ids', 'scores', 'beam_size', 'end_id', 'level', 'name'], varargs=None, keywords=None, defaults=(0, None))
103103
paddle.fluid.layers.row_conv ArgSpec(args=['input', 'future_context_size', 'param_attr', 'act'], varargs=None, keywords=None, defaults=(None, None))
104104
paddle.fluid.layers.multiplex ArgSpec(args=['inputs', 'index'], varargs=None, keywords=None, defaults=None)

paddle/fluid/operators/hierarchical_sigmoid_op.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class HierarchicalSigmoidOpMaker : public framework::OpProtoAndCheckerMaker {
108108
.AsDispensable();
109109
AddInput("Bias",
110110
"(LoDTensor, optional), The bias is a tensor with shape or "
111-
"[non_leaf_num, 1]"
111+
"[num_classes, 1]"
112112
"[num_classes - 1, 1].")
113113
.AsDispensable();
114114
AddOutput(

python/paddle/fluid/layers/nn.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4584,11 +4584,10 @@ def nce(input,
45844584

45854585
def hsigmoid(input,
45864586
label,
4587-
num_classes=None,
4587+
num_classes,
45884588
param_attr=None,
45894589
bias_attr=None,
45904590
name=None,
4591-
non_leaf_num=None,
45924591
path_table=None,
45934592
path_code=None,
45944593
is_custom=False,
@@ -4622,7 +4621,9 @@ def hsigmoid(input,
46224621
and :math:`D` is the feature size.
46234622
label (Variable): The tensor variable contains labels of training data.
46244623
It's a tensor with shape is :math:`[N \\times 1]`.
4625-
num_classes: (int), The number of classes, must not be less than 2. with default tree this has to be set
4624+
num_classes: (int), The number of classes, must not be less than 2. with default tree this has to be set,
4625+
it should never be None under is_custom=False, but while is_custom is true, it should be non leaf num
4626+
which indicates the num of classes using by binary classify.
46264627
param_attr (ParamAttr|None): The parameter attribute for learnable parameters/weights
46274628
of hsigmoid. If it is set to None or one attribute of ParamAttr, hsigmoid
46284629
will create ParamAttr as param_attr. If the Initializer of the param_attr
@@ -4634,15 +4635,14 @@ def hsigmoid(input,
46344635
is not set, the bias is initialized zero. Default: None.
46354636
name (str|None): A name for this layer(optional). If set None, the layer
46364637
will be named automatically. Default: None.
4637-
non_leaf_num: this defines the number of non-leaf nodes in costumed tree
46384638
path_table: (Variable|None) this variable can store each batch of samples' path to root,
46394639
it should be in leaf -> root order
46404640
path_table should have the same shape with path_code, and for each sample i path_table[i] indicates a np.array like
46414641
structure and each element in this array is indexes in parent nodes' Weight Matrix.
46424642
path_code: (Variable|None) this variable can store each batch of samples' code,
46434643
each code consist with every code of parent nodes. it should be in leaf -> root order
46444644
is_custom: (bool|False)using user defined binary tree instead of default complete binary tree, if costum is
4645-
set you need to set path_table/path_code/non_leaf_num, otherwise num_classes should be set
4645+
set you need to set path_table/path_code/num_classes, otherwise num_classes should be set
46464646
is_sparse: (bool|False)using sparse update instead of dense update, if set, the gradient
46474647
of W and input will be sparse.
46484648
@@ -4671,8 +4671,8 @@ def hsigmoid(input,
46714671
raise ValueError("path_code should not be None with costum tree")
46724672
elif (is_custom) and (path_table is None):
46734673
raise ValueError("path_table should not be None with costum tree")
4674-
elif (is_custom) and (non_leaf_num is None):
4675-
raise ValueError("non_leaf_num should not be None with costum tree")
4674+
elif (is_custom) and (num_classes is None):
4675+
raise ValueError("num_classes should not be None with costum tree")
46764676
else:
46774677
pass
46784678

@@ -4687,7 +4687,7 @@ def hsigmoid(input,
46874687
else:
46884688
weights = helper.create_parameter(
46894689
attr=helper.param_attr,
4690-
shape=[non_leaf_num, dim],
4690+
shape=[num_classes, dim],
46914691
is_bias=False,
46924692
dtype=input.dtype)
46934693
inputs = {
@@ -4708,7 +4708,7 @@ def hsigmoid(input,
47084708
else:
47094709
bias = helper.create_parameter(
47104710
attr=helper.bias_attr,
4711-
shape=[non_leaf_num, 1],
4711+
shape=[num_classes, 1],
47124712
is_bias=True,
47134713
dtype=input.dtype)
47144714
inputs['Bias'] = bias

python/paddle/fluid/tests/unittests/test_hsigmoid_op.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def hs_net_conf(self, is_sparse):
220220
input=emb,
221221
label=label,
222222
bias_attr=True,
223-
non_leaf_num=3,
223+
num_classes=3,
224224
path_table=path_table,
225225
path_code=path_code,
226226
is_custom=True,

python/paddle/fluid/tests/unittests/test_layers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def test_hsigmoid(self):
198198
layers.hsigmoid(
199199
input=x2,
200200
label=y2,
201-
non_leaf_num=6,
201+
num_classes=6,
202202
path_table=path_table,
203203
path_code=path_code,
204204
is_custom=True))

0 commit comments

Comments
 (0)