Reputation: 941
I am stuck at passing in 3 inputs (placeholders with different shapes) into a neural network's hidden layer.
This is what I have so far:
with tf.name_scope("Final_Check"):
# TODO: Is this the correct way to pass 3 inputs into the hidden layer?
final_layer1 = tf.layers.dense([self.final_time_input, self.final_request_input, self.final_stream_input],
500,
activation=tf.nn.relu,
name="final_hl1")
final_layer2 = tf.layers.dense(final_layer1,
500,
activation=tf.nn.relu,
name="final_h12")
final_layer3 = tf.layers.dense(final_layer2,
500,
activation=tf.nn.relu,
name="final_hl3")
final_output = tf.layers.dense(final_layer3,
500,
activation=tf.nn.relu,
name="final_output")
Placeholders:
Hidden Layers: all the final_layer[1-3] and final_output
I have tried Googling for some sample code but unable to find any.
Upvotes: 1
Views: 735
Reputation: 575
tf.layers.dense
expects tensor input. It is a list ([self.final_time_input, self.final_request_input, self.final_stream_input]
) in your case. You need to concatenate them by using tf.concat
such that
tf.concat([self.final_time_input, self.final_request_input, self.final_stream_input], axis=1)
Assuming that input tensors have a shape of [batch_size, feature_size]
where feature_size
can be different.
Upvotes: 2