singa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [singa] chrishkchris edited a comment on issue #552: SINGA-496 Implement softplus and softsign functions for tensor math
Date Sat, 16 Nov 2019 11:18:49 GMT
chrishkchris edited a comment on issue #552: SINGA-496 Implement softplus and softsign functions
for tensor math
URL: https://github.com/apache/singa/pull/552#issuecomment-554627773
 
 
   For example, you can change the logic as follows:
   aa=a is {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f}
   so cc=a is {-2.0f, 1.0f, 0.0f, 1.0f, 2.0f, 3.0f}
   p = SoftPlus(cc)
   and finally uses  EXPECT_NEAR to check if it is near log(exp(input)) + 1.0f
   This is an example:
   ```
   TEST_F(TensorMath, SoftPlusCpp) {
     Tensor aa = a.Clone();
     Tensor cc = aa - 3.0f;
     const float *dptr = cc.data<float>();
     EXPECT_NEAR(-2.0f, dptr[0], 1e-5);
     EXPECT_NEAR(-1.0f, dptr[1], 1e-5);
     EXPECT_NEAR(0.0f, dptr[2], 1e-5);
   
     Tensor p = SoftPlus(cc);
     const float *dptr1 = p.data<float>();
     EXPECT_NEAR(log(exp(-2.0f) + 1.0f), dptr1[0], 1e-5);
     EXPECT_NEAR(log(exp(-1.0f) + 1.0f), dptr1[1], 1e-5);
     EXPECT_NEAR(log(exp(0.0f) + 1.0f), dptr1[2], 1e-5);
     EXPECT_NEAR(log(exp(1.0f) + 1.0f), dptr1[3], 1e-5);
     EXPECT_NEAR(log(exp(2.0f) + 1.0f), dptr1[4], 1e-5);
   }
   ```
   

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