gpt4 book ai didi

tensorflow - 什么是 tf.bfloat16 "truncated 16-bit floating point"?

转载 作者:行者123 更新时间:2023-12-03 00:38:19 29 4
gpt4 key购买 nike

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

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

最佳答案

bfloat16 是一种 tensorflow 特定格式,与 IEEE 自己的 float16 不同,因此有了新名称。 b 代表 (Google) Brain。

基本上,bfloat16 是一个被截断为前 16 位的 float32。因此它的指数有相同的 8 位,而尾数只有 7 位。因此,float32 之间的转换很容易,并且由于它与 float32 的范围基本相同,因此可以最大限度地降低出现 NaN 的风险s 或从 float32 切换时梯度爆炸/消失

来自sources :

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

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

有关量化的更多信息 here .

关于tensorflow - 什么是 tf.bfloat16 "truncated 16-bit floating point"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44873802/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com