diff --git a/paddle/fluid/operators/collective/c_softmax_with_cross_entropy_op.cu b/paddle/fluid/operators/collective/c_softmax_with_cross_entropy_op.cu index 114c52f608f341..0e1d4640b93aeb 100644 --- a/paddle/fluid/operators/collective/c_softmax_with_cross_entropy_op.cu +++ b/paddle/fluid/operators/collective/c_softmax_with_cross_entropy_op.cu @@ -188,8 +188,7 @@ struct CSoftmaxWithCrossEntropyFunctor { eigen_softmax.device(*dev_ctx.eigen_device()) = (eigen_logits - - eigen_logits_max.reshape(batch_by_one).broadcast(one_by_class)) - .unaryExpr(phi::funcs::ValueClip()); + eigen_logits_max.reshape(batch_by_one).broadcast(one_by_class)); // step 3, obtain predict target phi::DenseTensor predicted_logits; @@ -346,8 +345,7 @@ struct CSoftmaxWithCrossEntropyProcessGroupFunctor { eigen_softmax.device(*dev_ctx.eigen_device()) = (eigen_logits - - eigen_logits_max.reshape(batch_by_one).broadcast(one_by_class)) - .unaryExpr(phi::funcs::ValueClip()); + eigen_logits_max.reshape(batch_by_one).broadcast(one_by_class)); // step 3, obtain predict target phi::DenseTensor predicted_logits; diff --git a/python/paddle/fluid/tests/unittests/c_softmax_with_cross_entropy_op.py b/python/paddle/fluid/tests/unittests/c_softmax_with_cross_entropy_op.py index 0217f7ee710f53..684c1c20bb1d7d 100644 --- a/python/paddle/fluid/tests/unittests/c_softmax_with_cross_entropy_op.py +++ b/python/paddle/fluid/tests/unittests/c_softmax_with_cross_entropy_op.py @@ -26,7 +26,7 @@ def stable_softmax(x): """Compute the softmax of vector x in a numerically stable way.""" # clip to shiftx, otherwise, when calc loss with # log(exp(shiftx)), may get log(0)=INF - shiftx = (x - np.max(x)).clip(-64.0) + shiftx = x - np.max(x) exps = np.exp(shiftx) return exps / np.sum(exps) @@ -88,13 +88,13 @@ def test_model(self, data_type="float32"): # get input data for rank 0 np.random.seed(0) input0 = np.random.uniform( - low=-10.0, high=10.0, size=(self.batch_size, local_elements) + low=-40.0, high=40.0, size=(self.batch_size, local_elements) ).astype(data_type) # get input data for rank 1 np.random.seed(1) input1 = np.random.uniform( - low=-10.0, high=10.0, size=(self.batch_size, local_elements) + low=-40.0, high=40.0, size=(self.batch_size, local_elements) ).astype(data_type) # get combined input data