Есть код с таким посылом
#learning parameters
learningRate = 0.01
trainingIteration = 30
batch_size = 100
x = tf.placeholder(tf.float32, [batch_size, 36], name='x')
W = tf.Variable(tf.zeros([36, batch_size]))
b = tf.Variable([0.1], name='bias')
y = tf.placeholder(tf.float32, [batch_size, 1], name='y')
with tf.name_scope('linearModel') as scope:
linear_model = tf.identity(tf.matmul(x, W) + b)
# ...
# ...
# ...
with tf.Session() as sess:
init = tf.global_variables_initializer()
sess.run(init)
for iteration in range(trainingIteration):
avg_cost = 0.
batch_list = []
for i in range(batch_size):
rand = randint(0, len(dataset))
batch_list.append(dataset[rand])
dataDict = dataset[rand]
datasetX = [*map(lambda data: data['inData'], batch_list)]
datasetY = [*map(lambda data: [data['outData']], batch_list)]
sess.run(optimizer, feed_dict = {x: datasetX, y: datasetY})
if iteration % 10 == 0:
print(sess.run(x))
По сути, я в итерации беру 100 случайных значений из датасета, в x у нас 36 значений, в y - одно. Они точно имеют питоновский тип float. Но вот этот код питон ругается, говорит: "You must feed a value for placeholder tensor 'x' with dtype float and shape [100, 36]"
При этом, если изменить запихивание элементов в подаваемый массив на
for i in range(batch_size -1):
rand = randint(0, len(dataset))
batch_list.append(dataset[rand])
, то ошибка следующая: cannot feed value of shape (99, 36) for Tensor 'x:0' which has shape '(100, 36)'
Где копать? Полагаю, ошибка должна быть простой, первый раз сталкиваюсь, по сути, с питоном и ML.