我将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,11]的另一个值作为
与另一个维度[BATCH_SIZE,10]的占位符节点连接起来。combined_data_for_MLP = tf.concat(feed_data, output_sequential, 1)
但是,我收到以下错误
TypeError:期望的字符串或类似字节的对象
如何根据需要连接?
答案 0 :(得分:1)
查看tf.concat的文档:https://www.tensorflow.org/api_docs/python/tf/concat
你会看到,对于被称为“值”的连接对象的参数,它必须是单个张量或张量列表。因此,函数调用你的情况应该是tf.concat([feed_data, output_sequential], 1)