singa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [singa] Wentong-DST commented on a change in pull request #552: SINGA-496 Implement softplus and softsign functions for tensor math
Date Wed, 13 Nov 2019 17:03:49 GMT
Wentong-DST 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_r345883207
 
 

 ##########
 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:
   Hi @chrishkchris , will add test cases and rerun build pipelines. Thanks for reviewing!

----------------------------------------------------------------
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

Mime
View raw message