Skip to content

definition of relative error #154

Description

@j4yan

Currently the relative error when the reference value is zero is defined using an epsilon to avoid division by zero; see https://github.com/ROCmSoftwarePlatform/composable_kernel/blob/313bbea5886850acab286f45e9d9816cf0b0dca0/library/include/ck/library/host_tensor/host_tensor.hpp#L327

The problem is that this approve results in very large relative error even if the absolute error is small. For example, (v = 1e-8, v_ref = 0, eps = 1e-10), then ref_diff = 100. We can use more reasonable definition, for example:
rel_diff = (v - v_ref) / max(|v|, |v_ref|). See https://en.wikipedia.org/wiki/Relative_change_and_difference for other alternatives.

Activity

  1. j4yan commented on Mar 25, 2022

    @j4yan
    ContributorAuthor

    The suggested definition doesn't work when v = v_ref = 0 (most likely happens for integers), so we should check it first.

  2. asroy commented on Mar 30, 2022

    @asroy
    Contributor

    what about:
    rel_diff = (v - v_ref) / max(|v|, |v_ref|, |eps|)?

  3. j4yan commented on Mar 31, 2022

    @j4yan
    ContributorAuthor

    It covers the corner case I mentioned above, but why do we introduce a user-defined and hard-coded variable?

  4. aosewski commented on Mar 31, 2022

    @aosewski
    Collaborator

    In the mentioned wiki article all relative difference definitions are not defined when the f(x,y) is equal to zero. IMHO this is the special case which should be treated separately.

  5. j4yan commented on Mar 31, 2022

    @j4yan
    ContributorAuthor

    @asroy Agree with @aosewski.

  6. locked and limited conversation to collaborators on Apr 1, 2022
  7. converted this issue into a discussion #172 on Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions