小编use*_*249的帖子

为什么我的线性回归会得到nan值而不是学习值?

我正在运行以下代码:

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)

python tensorflow

3
推荐指数
1
解决办法
2007
查看次数

标签 统计

python ×1

tensorflow ×1