tensorflow学习(tensorflow入门与基本使用)

tensorflow入门与基本使用

  • 计算图(computation graphy)

计算图(computation graphy)

计算图是由一个个节点和连接各个节点的边组成,因此要定义一个计算图,只需要定义好各个节点以及节点的输入输出(对应计算图的边)。节点代表各种操作,如加法、乘法、卷积运算等等,输入输出主要是各种数据(tensor)。

import tensorflow as tf

# Create a Constant op that produces a 1x2 matrix.  创建产生1x2矩阵的常量运算The op is
# added as a node to the default graph.
# 作为节点添加到默认图形中。
# The value returned by the constructor represents the output  构造函数返回的值表示输出
# of the Constant op.
matrix1 = tf.constant([[3., 3.]])

# Create another Constant that produces a 2x1 matrix.
matrix2 = tf.constant([[2.],[2.]])

# Create a Matmul op that takes 'matrix1' and 'matrix2' as inputs.
# The returned value, 'product', represents the result of the matrix
# multiplication.
product = tf.matmul(matrix1, matrix2)

你可能感兴趣的:(Tensorflow入门,tensorflow,人工智能,算法,机器学习)