2017-06-21 117 views
0

級聯LSTM輸出I有[BATCH_SIZE,1]定義爲這個使用佔位符

cell = tf.contrib.rnn.LSTMCell(num_hidden,state_is_tuple=True) 
val, _ = tf.nn.dynamic_rnn(cell, sequential_feed_data, dtype=tf.float32) 
val = tf.transpose(val, [1, 0, 2]) 
last = tf.gather(val, int(val.get_shape()[0]) - 1) 
weight_sequential = tf.Variable(tf.truncated_normal([num_hidden,int(target.get_shape()[1])])) 
bias_sequential = tf.Variable(tf.constant(0.1, shape=[target.get_shape()[1]])) 
output_sequential = tf.nn.softmax(tf.matmul(last, weight_sequential) + bias_sequential) 

一個LSTM此output_sequential具有的尺寸。我希望與[BATCH_SIZE,10]維的另一佔位符節點來連接它利用tf.concat得到維度的其他值[BATCH,11]如

combined_data_for_MLP = tf.concat(feed_data, output_sequential, 1) 

然而,我得到以下錯誤

TypeError: expected string or bytes-like object

如何根據需要連接?

回答

1

結帳的tf.concat的文檔:https://www.tensorflow.org/api_docs/python/tf/concat

你會看到,對於對象(或多個)參數被串接所謂的「價值」,它必須是單個或張的列表張量。因此,您的案件的函數調用應該是tf.concat([feed_data, output_sequential], 1)