Sanjay
Sanjay

Reputation: 505

Concatenating LSTM output with a placeholder

I have an LSTM defined as this

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)

This output_sequential has dimensions [BATCH_SIZE, 1]. I wish to concatenate it with another placeholder node of dimension [BATCH_SIZE, 10] by using tf.concat to get another value of dimension [BATCH, 11] as

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

However, I get the following error

TypeError: expected string or bytes-like object

How do I concatenate as desired?

Upvotes: 0

Views: 395

Answers (1)

Neel Kant
Neel Kant

Reputation: 36

Checkout the documentation for tf.concat: https://www.tensorflow.org/api_docs/python/tf/concat

You'll see that for the argument for the object(s) being concatenated called "values", it must either be a single tensor or a list of tensors. Hence, the function call for your case should be tf.concat([feed_data, output_sequential], 1)

Upvotes: 2

Related Questions