开发者社区> 问答> 正文

什么是tf.bfloat16“截断的16位浮点”?

如https://www.tensorflow.org/versions/r0.12/api_docs/python/framework/tensor_types中列出的tf.float16和tf.bfloat16有什么区别?

另外,“量化整数”是什么意思?

展开
收起
祖安文状元 2020-02-23 16:35:51 7993 0
1 条回答
写回答
取消 提交回答
  • bfloat16是特定于张量流的格式,与IEEE自己的格式不同float16,因此是新名称。

    基本上blfoat16是float32将其截断为前16位。因此它具有相同的8位指数,而尾数只有7位。因此,从和转换很容易float32,并且因为它的范围基本相同float32,所以NaN从切换时,使s或爆炸/消失梯度的风险降到最低float32。

    从来源:

    // Compact 16-bit encoding of floating point numbers. This representation uses
    // 1 bit for the sign, 8 bits for the exponent and 7 bits for the mantissa.  It
    // is assumed that floats are in IEEE 754 format so the representation is just
    // bits 16-31 of a single precision float.
    //
    // NOTE: The IEEE floating point standard defines a float16 format that
    // is different than this format (it has fewer bits of exponent and more
    // bits of mantissa).  We don't use that format here because conversion
    // to/from 32-bit floats is more complex for that format, and the
    // conversion for this format is very simple.
    
    

    对于量化的整数,它们旨在替换受过训练的网络中的浮点以加快处理速度。基本上,它们是实数的定点编码,尽管选择的工作范围是代表在网络的任何给定点处观察到的分布。

    2020-02-23 16:35:58
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载