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



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

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

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

最新更新