摘要:
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt x_data = np.random.rand(100) noise = np.random.normal(0,0.01,x_data.shape) y_data = x_data*0.1 + 0.2 + noise plt.scatter(x_da 阅读全文
摘要:
import tensorflow as tf # Fetch:可以在session中同时计算多个tensor或执行多个操作 # 定义三个常量 input1 = tf.constant(3.0) input2 = tf.constant(2.0) input3 = tf.constant(5.0) # 加法op add = tf.add(input2,input3) # 乘法op mul = tf 阅读全文
摘要:
import tensorflow as tf # 定义一个变量 x = tf.Variable([1,2]) # 定义一个常量 a = tf.constant([3,3]) # 减法op sub = tf.subtract(x, a) # 加法op add = tf.add(x,sub) # 所有变量初始化 init = tf.global_variables_initializer() wit 阅读全文
摘要:
import tensorflow as tf # 创建一个常量 m1 = tf.constant([[3,3]]) # 创建一个常量 m2 = tf.constant([[2],[3]]) # 矩阵乘法op product = tf.matmul(m1, m2) print(product) # 定义会话 sess = tf.Session() # 调用sess中的run方法来执行矩阵乘法op 阅读全文