Передача ndarrays для подачи dict возвращает - «Вы должны передать значение для тензора-заполнителя» - PullRequest
0 голосов
/ 05 июня 2019

Я новичок в tenorflow.Я хочу передать обучающие данные (Xs и Ys - это 3d ndarrays [85,31951,9] и [85,31951,1]) для входных данных и целей заполнителей внутри блока tf.session.

85 сэмплов, 31951 отметок времени и 9 функций в X.

Я попытался передать np.random.random((85, 31951, 9)) в feed dict, просто чтобы увидеть, есть ли какие-либо проблемыс моими размерами входных данных.Тем не менее ошибка сохраняется.

"Вы должны передать значение для тензора-заполнителя 'Placeholder' с плавающей точкой dtype и формы [85,31951,9]".

Если я поверну первое измерение (примеры) от 85 до None, код выполняется, но я сталкиваюсь с Unknown shape ошибкой в ​​tf.gather.Я могу опубликовать больше кода, если это необходимо.Любая помощь приветствуется.

with tf.Session(graph=lstm_graph) as sess: 
    tf.global_variables_initializer().run()

    x_train_IV_nd, x_train_DV_nd = prep_data()
    print(np.shape(x_train_IV_nd))
    print(type(x_train_IV_nd))
    # print(x_train_IV_nd.dtype)
    learning_rates_to_use = [
        config.init_learning_rate * (
            config.learning_rate_decay ** max(float(i + 1 - config.init_epoch), 0.0)
        ) for i in range(config.max_epoch)]

    for epoch_step in range(config.max_epoch):
        current_lr = learning_rates_to_use[epoch_step]
        train_loss, _ = sess.run([loss, minimize], feed_dict={inputs: np.random.random((85, 31951, 9)), targets: np.random.random((85, 31951, 1))})

И мои заполнители для ввода входных данных и целей:

inputs = tf.placeholder(tf.float32, shape = (85,31951,9))  
targets = tf.placeholder(tf.float32, shape = (85,31951,1)) 

Сетевые настройки:

class RNNConfig():
    input_size=9 
    num_steps=31951   
    num_units = 128  
    lstm_size=9
    num_layers=9
    keep_prob=0.8
    batch_size = 85
    init_learning_rate = 0.001
    learning_rate_decay = 0.99
    init_epoch = 5
    max_epoch = 50

Ошибка:

 #[[Node: Placeholder = Placeholder[dtype=DT_FLOAT, shape=[85,31951,9], _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]
     [[Node: rnn/transpose_1/_17 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_170_rnn/transpose_1", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/antpc/Documents/Python/testpycharm/my_csv.py", line 198, in <module>


    tf.global_variables_initializer().run()
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 2377, in run
    _run_using_default_session(self, feed_dict, self.graph, session)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 5215, in _run_using_default_session
    session.run(operation, feed_dict)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 900, in run
    run_metadata_ptr)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1135, in _run
    feed_dict_tensor, options, run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1316, in _do_run
    run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1335, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder' with dtype float and shape [85,31951,9]
     [[Node: Placeholder = Placeholder[dtype=DT_FLOAT, shape=[85,31951,9], _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]
     [[Node: rnn/transpose_1/_17 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_170_rnn/transpose_1", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

Caused by op 'Placeholder', defined at:
  File "/home/antpc/Documents/Python/testpycharm/my_csv.py", line 145, in <module>
    ##inputs = tf.placeholder(tf.float32, shape = (85,31951,9))  (85,31951,9)##
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/array_ops.py", line 1808, in placeholder
    return gen_array_ops.placeholder(dtype=dtype, shape=shape, name=name)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 4848, in placeholder
    "Placeholder", dtype=dtype, shape=shape, name=name)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 3392, in create_op
    op_def=op_def)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 1718, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

###InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'Placeholder' with dtype float and shape [85,31951,9] ####
     [[Node: Placeholder = Placeholder[dtype=DT_FLOAT, shape=[85,31951,9], _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]
     [[Node: rnn/transpose_1/_17 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_170_rnn/transpose_1", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...