Tensorflow 1.10 с python 3.5.6 (InvalidArgumentError: Вы должны передать значение для тензора-заполнителя 'input_8 / InputX' с dtype float) - PullRequest
0 голосов
/ 19 декабря 2018

Мой код :

import tensorflow as tf
import numpy as np

x_input=np.linspace(0,10,100)
y_input=5*x_input+2.5


#model parameters
W = tf.Variable(tf.random_normal([1]), name='weight')
#bias
b = tf.Variable(tf.random_normal([1]), name='bias')

#placeholders
with tf.name_scope('input'):
 X=tf.placeholder(tf.float32,name='InputX')

 Y=tf.placeholder(tf.float32, name='InputY')

#model
with tf.name_scope('model'):
 Y_pred=tf.add(tf.multiply(X,W),b)

#loss
with tf.name_scope('loss'):
 loss = tf.reduce_mean(tf.square(Y_pred -Y ))
#training algorithm
optimizer = tf.train.GradientDescentOptimizer(0.01)
train = optimizer.minimize(loss)

#init = tf.initialize_all_variables() #for TF version < 1.0
init=tf.global_variables_initializer()

#starting the session session 
sess = tf.Session()
sess.run(init)
cost=tf.summary.scalar("loss", loss)
sess.run(init)
merged_summary_op = tf.summary.merge_all() 
summary_writer = tf.summary.FileWriter('E:/pythonScripts/.spyder-py3/', 
graph=tf.get_default_graph())
# training the line
for step in range(1000):
    #sess.run(train)
    _, c, summary=sess.run([train, loss, merged_summary_op], feed_dict= 
     {X: x_input, Y: y_input})
     summary_writer.add_summary(summary,step)
     if step%50==0:
         print(c)

Я получаю следующую ошибку:

InvalidArgumentError: Необходимо указать значение для тензора-заполнителя 'input_8 /InputX 'с плавающей точкой dtype [[Node: input_8 / InputX = Placeholderdtype = DT_FLOAT, shape =, _device = "/ job: localhost / replica: 0 / task: 0 / device: CPU: 0"]]

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...