我正在运行以下代码:
import tensorflow as tf
# data set
x_data = [10., 20., 30., 40.]
y_data = [20., 40., 60., 80.]
# try to find values for w and b that compute y_data = W * x_data + b
# range is -100 ~ 100
W = tf.Variable(tf.random_uniform([1], -1000., 1000.))
b = tf.Variable(tf.random_uniform([1], -1000., 1000.))
X = tf.placeholder(tf.float32)
Y = tf.placeholder(tf.float32)
# my hypothesis
hypothesis = W * X + b
# Simplified cost function
cost = tf.reduce_mean(tf.square(hypothesis - Y))
# …Run Code Online (Sandbox Code Playgroud)