이홍재
이홍재

Reputation: 21

How to put two inputs into tensorflow lambda layer

How do you put two inputs into tensorflow lambda layer? I have tried:

channel_input=Input(shape=(4,),dtype='complex64',name='channel_input')

...
realed_ffted_channel1 = Dense(2*N_c,activation='relu')(realed_ffted_channel)
precoded_data = Lambda(lambda x,y: tf.concat([x,y],1))([encoding_x,realed_ffted_channel1])

However, I receive this error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-29-9332eac3e7cf> in <module>()
     10 
     11 #Precoding Encoder
---> 12 precoded_data = Lambda(lambda x,y: tf.concat([x,y],1))([encoding_x,realed_ffted_channel1])
     13 encoder_data = Dense(3*N_c,activation='relu')(precoded_data)
     14 encoder_data1 = Dense(N_c,activation='relu')(encoder_data)

1 frames
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/layers/core.py in call(self, inputs, mask, training)
    820       arguments['training'] = training
    821     with variable_scope.variable_creator_scope(self._variable_creator):
--> 822       return self.function(inputs, **arguments)
    823 
    824   def _variable_creator(self, next_creator, **kwargs):

TypeError: <lambda>() missing 1 required positional argument: 'y'

implying the second input y was not passed.

Upvotes: 1

Views: 2040

Answers (1)

Dr. Snoopy
Dr. Snoopy

Reputation: 56367

You can do this:

precoded_data = Lambda(lambda x: tf.concat([x[0], x[1]],1))([encoding_x,realed_ffted_channel1])

Note that for this specific use case you can just also use the Concatenate layer.

Upvotes: 5

Related Questions