在 Tensorflow 文档中的整数值或数字值中使用下划线

Use of underscore in interger values or Number values in Tensorflow documentation

如果我们查看下面的文档 https://www.tensorflow.org/recommenders/examples/basic_retrieval,它会在整数值中使用下划线 (_),例如批量大小。这个下划线是什么意思,跟小数点一样。

下划线是为了提高可读性,没有更深的含义。有关详细信息,请参阅 this。这是一个例子:

import tensorflow

ds1 = tf.data.Dataset.random(seed=4).take(2_000)
print(len(list(ds1.map(lambda x: x))))
ds1 = tf.data.Dataset.random(seed=4).take(200_000)
print(len(list(ds1.map(lambda x: x))))
2000
200000