简体   繁体   English

TensorFlow2.0 会减少不必要的计算吗?

[英]Will TensorFlow2.0 trim unncessary computations?

Will TensorFlow 2.0 be able to trim unnecessary computations? TensorFlow 2.0 是否能够减少不必要的计算?

For example,例如,

a = tf.constant(1.0)
for i in range(10):
  c = a + 1
  a = a + 1
print(a)

In TF1.x, c=a+1 won't be computed.在 TF1.x 中,不会计算c=a+1 Will TF2.0 automatically detect c=a+1 is not used so it doesn't do the computation? TF2.0 会自动检测到c=a+1没有被使用所以它不进行计算吗?

It won't be computed.它不会被计算。 The preprocessor will detect it is never used and the program won't take into account.预处理器会检测到它从未被使用过,程序不会考虑。 You can (not recommended) suppress warnings about unused stuff, instead, you should take care of the unused things.您可以(不推荐)抑制有关未使用内容的警告,相反,您应该注意未使用的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM