简体   繁体   中英

Will TensorFlow2.0 trim unncessary computations?

Will TensorFlow 2.0 be able to trim unnecessary computations?

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. Will TF2.0 automatically detect c=a+1 is not used so it doesn't do the computation?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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