Giter Club home page Giter Club logo

Comments (7)

anakinxc avatar anakinxc commented on June 12, 2024

Hi @hy928302776

spu 目前是用的 fixedpoint 来编码浮点数

0.99 是一个需要很多 fraction bits 才可以相对精确表达的一个值

如果有实际需求,可以尝试使用 fm128+比较多的 fraction bits 来一定程度的改善精度损失

from spu.

hy928302776 avatar hy928302776 commented on June 12, 2024

这个有什么好的办法解决精度丢失问题吗?我这边该怎么做呢?上边说的 尝试使用 fm128+比较多的 fraction bits 来一定程度的改善精度损失 这个怎么做

from spu.

anakinxc avatar anakinxc commented on June 12, 2024

这个有什么好的办法解决精度丢失问题吗?我这边该怎么做呢?上边说的 尝试使用 fm128+比较多的 fraction bits 来一定程度的改善精度损失 这个怎么做

这个做个例子

    runtime_config={
        'protocol': spu.spu_pb2.ABY3,
        'field': spu.spu_pb2.FM128
    },

如果默认的依然不够精度,可以试一下加一个

        'fxp_fraction_bits': 30

30 是一个可以配置的选项,可以根据自己的 fxp 需求计算一下大概需要多少 fxp bits

from spu.

hy928302776 avatar hy928302776 commented on June 12, 2024

DEFAULT_SEMI2K_RUNTIME_CONFIG = {
'protocol': spu.spu_pb2.SEMI2K,
'field': spu.spu_pb2.FM128,
'fxp_fraction_bits': 30,
}
我们的是两方计算,使用的这个协议配置,测试了下,还是不行,修改了fxp_fraction_bits的值也不行。计算:
199999.97 - 100.01 结果返回还是 199899.95

from spu.

anakinxc avatar anakinxc commented on June 12, 2024

DEFAULT_SEMI2K_RUNTIME_CONFIG = { 'protocol': spu.spu_pb2.SEMI2K, 'field': spu.spu_pb2.FM128, 'fxp_fraction_bits': 30, } 我们的是两方计算,使用的这个协议配置,测试了下,还是不行,修改了fxp_fraction_bits的值也不行。计算: 199999.97 - 100.01 结果返回还是 199899.95

我仔细研究了一下现在大概是这样的的,用 FM64 举个例子:

199999.97 encode 到 fxp 是 52428791808
100.01 encode 到 fxp 是 26217022

52428791808 - 26217022 = 52402574786

result = 52402574786/(2^18)

这个数值在 f32 的时候是 199899.953125,所以结果出来会是 .95
如果用 f64, 这个值会是 199899.95874786376953

我们会在后续更新里尝试支持 f64 来解决这个精度问题

from spu.

hy928302776 avatar hy928302776 commented on June 12, 2024

from spu.

anakinxc avatar anakinxc commented on June 12, 2024

这个f64啥时间更新上去呢,我们着急使用发自我的 iPhone在 2023年5月18日,18:05,anakinxc @.> 写道: DEFAULT_SEMI2K_RUNTIME_CONFIG = { 'protocol': spu.spu_pb2.SEMI2K, 'field': spu.spu_pb2.FM128, 'fxp_fraction_bits': 30, } 我们的是两方计算,使用的这个协议配置,测试了下,还是不行,修改了fxp_fraction_bits的值也不行。计算: 199999.97 - 100.01 结果返回还是 199899.95 我仔细研究了一下现在大概是这样的的,用 FM64 举个例子: 199999.97 encode 到 fxp 是 52428791808 100.01 encode 到 fxp 是 26217022 52428791808 - 26217022 = 52402574786 result = 52402574786/(2^18) 这个数值在 f32 的时候是 199899.953125,所以结果出来会是 .95 如果用 f64, 这个值会是 199899.95874786376953 我们会在后续更新里尝试支持 f64 来解决这个精度问题 —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.>

这个我们会尽快更新的

from spu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.