You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TensorFlow文档中整数值与数值下划线的含义探究:下划线是否等同于小数点?

Underscores in Numeric Values in TensorFlow Documentation: What They Mean

Hey there! Awesome question—those underscores you're seeing in numbers (like 10_000 for batch sizes) have nothing to do with decimal points. Let's break this down simply:

  • It's a Python readability feature: Introduced in Python 3.6, underscores act as digit separators for numeric literals. They’re purely there to make large numbers easier to scan at a glance—think of them like commas you’d use when writing numbers (e.g., 10,000 becomes 10_000 in code).
  • No impact on value or type: The Python interpreter completely ignores these underscores. So 10_000 is identical to 10000—same integer value, same data type. A decimal point (.) would change things entirely (e.g., 10.000 is a float equal to 10.0), but underscores don’t alter the number at all.
  • Why TensorFlow uses it: You’ll spot this for values like batch sizes, dataset counts, or hyperparameters where large numbers are common. It’s a standard Python best practice now, so it’s used across TensorFlow docs and other Python-based ML codebases to keep code clean and easy to read.

This is just syntax sugar for readability—no hidden functionality here!

内容的提问来源于stack exchange,提问作者sakeesh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 16:32:41