Skip to content

update mish functor#17916

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
SinM9:mish_functor_sin
Jul 28, 2020
Merged

update mish functor#17916
opencv-pushbot merged 1 commit intoopencv:3.4from
SinM9:mish_functor_sin

Conversation

@SinM9
Copy link
Copy Markdown
Contributor

@SinM9 SinM9 commented Jul 22, 2020

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under OpenCV (BSD) License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@dkurt
Copy link
Copy Markdown
Member

dkurt commented Jul 22, 2020

@YashasSamaga, Can you please share your approach of determining eps value? I mean why in #17624 (comment) x > 8.688687f is proposed?

@YashasSamaga
Copy link
Copy Markdown
Contributor

YashasSamaga commented Jul 22, 2020

I plotted the errors of old mish functor and return x; against 128-bit reference values. I just kept zooming into the graph and eyeballed the intersection (the plot displays the bias for the y-axis which happened to be 8.688687f).

I don't think the errors in estimating this threshold will make a big difference but it can be done systematically:

#include <cmath>
#include <iostream>
#include <iomanip>
#include <limits>

int main ()
{
    std::cout << std::setprecision(std::numeric_limits<float>::max_digits10);
    for (float x = 8; x < 9; x = std::nextafter(x, 10.0f))
    {
        const long double ldx = x;
        float y = ldx  * std::tanh(std::log1p(std::exp(ldx)));
        if (x == y)
        {
            std::cout << x << std::endl;
            break;
        }
    }
}

This gives me 8.70648861.

@SinM9 SinM9 closed this Jul 22, 2020
@SinM9 SinM9 force-pushed the mish_functor_sin branch from 2e9291e to 971ae00 Compare July 22, 2020 18:22
@dkurt dkurt reopened this Jul 22, 2020
Copy link
Copy Markdown
Member

@dkurt dkurt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@dkurt dkurt self-assigned this Jul 24, 2020
@opencv-pushbot opencv-pushbot merged commit e4d573a into opencv:3.4 Jul 28, 2020
@alalek alalek mentioned this pull request Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants