replace -100 to kIgnoreIndex

revert-14666-feature/estiminate_flops
jerrywgz 7 years ago
parent 13e254faed
commit 3df0538940

@ -18,6 +18,7 @@ namespace paddle {
namespace operators {
using framework::Tensor;
const int kIgnoreIndex = -100;
class SigmoidCrossEntropyWithLogitsOp : public framework::OperatorWithKernel {
public:
@ -100,11 +101,11 @@ class SigmoidCrossEntropyWithLogitsOpMaker
AddOutput("Out",
"(Tensor, default Tensor<float>), a 2-D tensor with shape N x D "
" of elementwise logistic losses.");
AddAttr<int>(
"ignore_index",
"(int, default -100), Specifies a target value that is ignored and"
"does not contribute to the input gradient.")
.SetDefault(-100);
AddAttr<int>("ignore_index",
"(int, default kIgnoreIndex), Specifies a target value that "
"is ignored and"
"does not contribute to the input gradient.")
.SetDefault(kIgnoreIndex);
AddComment(R"DOC(
SigmoidCrossEntropyWithLogits Operator.

@ -170,6 +170,8 @@ __all__ = [
'bilinear_tensor_product',
]
kIgnoreIndex = -100
def fc(input,
size,
@ -1103,7 +1105,7 @@ def dropout(x,
return out
def cross_entropy(input, label, soft_label=False, ignore_index=-100):
def cross_entropy(input, label, soft_label=False, ignore_index=kIgnoreIndex):
"""
**Cross Entropy Layer**
@ -4796,7 +4798,7 @@ def multiplex(inputs, index):
def softmax_with_cross_entropy(logits,
label,
soft_label=False,
ignore_index=-100,
ignore_index=kIgnoreIndex,
numeric_stable_mode=False,
return_softmax=False):
"""
@ -7892,7 +7894,10 @@ def mul(x, y, x_num_col_dims=1, y_num_col_dims=1, name=None):
@templatedoc()
def sigmoid_cross_entropy_with_logits(x, label, ignore_index=-100, name=None):
def sigmoid_cross_entropy_with_logits(x,
label,
ignore_index=kIgnoreIndex,
name=None):
"""
${comment}

Loading…
Cancel
Save