计算图中的操作
# python 3.6
import tensorflow as tf
import numpy as np
sess = tf.Session()
# 将张量和占位符对象组成一个计算图,创建一个简单的分类器
# 一、计算图中的操作
# 1. 声明张量和占位符,创建numpy数组,传入计算图操作
x_vals = np.array([1.,3.,5.,7.,9.])
x_data = tf.placeholder(tf.float32)
m_const = tf.constant(3.)
my_product = tf.multiply(x_data, m_const)
for x_val in x_vals:
print(sess.run(my_product, feed_dict={
x_data: x_val}))
#输出:
# 3.0
# 9.0
# 15.0
# 21.0
# 27.0
计算图中的操作
工作原理:
嵌入Layer
# python 3.6
import tensorflow as tf
import numpy as np
sess = tf.Session()
# 二、TensorFlow的嵌入layer