0

我有一个 LSTM 定义为

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)

此 output_sequential 具有维度 [BATCH_SIZE, 1]。我希望通过使用 tf.concat 将其与维度 [BATCH_SIZE, 10] 的另一个占位符节点连接起来,以获得维度 [BATCH, 11] 的另一个值作为

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

但是,我收到以下错误

TypeError:预期的字符串或类似字节的对象

如何根据需要连接?

4

1 回答 1

2

查看 tf.concat 的文档:https ://www.tensorflow.org/api_docs/python/tf/concat

您会看到,对于被连接的对象的参数称为“值”,它必须是单个张量或张量列表。因此,您的案例的函数调用应该是 tf.concat([feed_data, output_sequential], 1)

于 2017-06-21T23:54:29.837 回答