You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@singa.apache.org by GitBox <gi...@apache.org> on 2019/11/13 04:30:41 UTC

[GitHub] [singa] chrishkchris commented on a change in pull request #552: SINGA-496 Implement softplus and softsign functions for tensor math

chrishkchris commented on a change in pull request #552: SINGA-496 Implement softplus and softsign functions for tensor math
URL: https://github.com/apache/singa/pull/552#discussion_r345563360
 
 

 ##########
 File path: test/singa/test_tensor_math.cc
 ##########
 @@ -120,6 +120,32 @@ TEST_F(TensorMath, SignCpp) {
   EXPECT_EQ(1.0f, dptr1[2]);
 }
 
+TEST_F(TensorMath, SoftPlusCpp) {
+  Tensor aa = a.Clone();
+  Tensor cc = aa - 1.0f;
+  const float *dptr = aa.data<float>();
+  EXPECT_NEAR(0.0f, dptr[0], 1e-5);
+  EXPECT_NEAR(1.0f, dptr[1], 1e-5);
+
+  Tensor p = SoftPlus(cc);
+  const float *dptr1 = p.data<float>();
+  EXPECT_EQ(log(2.0f), dptr1[0]);
+  EXPECT_EQ(log(exp(1) + 1.0f), dptr1[1]);
+}
+
+TEST_F(TensorMath, SoftSignCpp) {
+  Tensor aa = a.Clone();
+  Tensor cc = aa - 1.0f;
+  const float *dptr = aa.data<float>();
+  EXPECT_NEAR(0.0f, dptr[0], 1e-5);
+  EXPECT_NEAR(1.0f, dptr[1], 1e-5);
+
+  Tensor p = SoftSign(cc);
+  const float *dptr1 = p.data<float>();
+  EXPECT_EQ(0.0f, dptr1[0]);
+  EXPECT_EQ(1.0f / 3, dptr1[1]);
+}
+
 
 Review comment:
   @Wentong-DST 
   Could you add the cuda test, namely SoftSignCuda and SoftPlusCuda after the line 804 (#ifdef USE_CUDA) . After that, could you please run the test once? Thanks!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services