TensorFlow之编程模式

Posted xyqiu90-365

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TensorFlow之编程模式相关的知识,希望对你有一定的参考价值。

主要编程模式有:

(1)命令式编程   ——   Torch

(2)符号式编程   ——   TensorFlow

 

命令式编程:

易理解,命令语句基本没优化:C,Java,C++,Python

 

符号式编程:

涉及较多的嵌入和优化,运行速度有同比提升

例如:

1 import tensorflow as tf
2 
3 a = tf.constant(2)
4 b = tf.constant(3)
5 c = tf.multiply(a, b)
6 d = tf.add(c, 1)
7 
8 with tf.Session() as sess:
9     print (sess.run(d))

 

以上是关于TensorFlow之编程模式的主要内容,如果未能解决你的问题,请参考以下文章