0.2 TensorFlow 可以做什么 ?
目前主要是用于机器学习,这样说有点不亲民,笔者理解是可以将数据转化为向量描述并且构建相应的计算流图都是可以使用的。 举个例子吧,虽然不知道恰不恰当。 比如我们在计算 时,可以构建一个二叉树
这棵二叉树的中序遍历就是上面的表达式,也就是说这个表达式可以转化成一个形如二叉树的图,而 TensorFlow正好可以计算这个图。下面给出代码,看不懂没关系,只要理解代码流程是对图(二叉树)的计算就可以了,下面会介绍如何使用Tensorflow
# coding: utf-8import tensorflow as tfa, b, c, d = tf.constant(1), tf.constant(2), tf.constant(3),tf.constant(4)add = tf.add(a,b)mul = tf.multiply(add, c)sub = tf.subtract(mul, d)with tf.Session() as sess: print(sess.run(sub))# output: # 5
目前主要是用于机器学习,这样说有点不亲民,笔者理解是可以将数据转化为向量描述并且构建相应的计算流图都是可以使用的。 举个例子吧,虽然不知道恰不恰当。 比如我们在计算 时,可以构建一个二叉树
这棵二叉树的中序遍历就是上面的表达式,也就是说这个表达式可以转化成一个形如二叉树的图,而 TensorFlow正好可以计算这个图。下面给出代码,看不懂没关系,只要理解代码流程是对图(二叉树)的计算就可以了,下面会介绍如何使用Tensorflow
# coding: utf-8import tensorflow as tfa, b, c, d = tf.constant(1), tf.constant(2), tf.constant(3),tf.constant(4)add = tf.add(a,b)mul = tf.multiply(add, c)sub = tf.subtract(mul, d)with tf.Session() as sess: print(sess.run(sub))# output: # 5