在Tensorflow源代码中的Bool变量的初始化

Initialization of bool variables in tensorflow source code

本文关键字:Bool 初始化 变量 Tensorflow 源代码      更新时间:2023-10-16

tf.ConfigProto configproto的tensorflow源代码中,布尔类型变量以一种奇怪的方式启动:

// If true, the allocator does not pre-allocate the entire specified
// GPU memory region, instead starting small and growing as needed.
bool allow_growth = 4;
bool force_gpu_compatible = 8;
bool use_rpc_for_inprocess_master = 1;
bool allow_soft_placement = 7;
...

为什么这些布尔不用trueflase01启动?尽管值不是0在C 中被认为是true,但这样做的含义是什么?4、8、7,似乎没有特定的规则可以使用哪个数字。

这些不是可变初始化。这些是消息中与这些字段关联的标签。有关更多信息,请查看此处。