I am trying to write a Lambda
layer in Keras which calls a function connection
, that runs a loop for i in range(0,k)
where k
Tmodel = Sequential()
x = layers.Input(shape=[1,]) # Lambda on single input
out1 = layers.Lambda(lambda x: x ** 2)(x)
y = layers.Input(shape=[1,]) # Lambda on multiple inputs
z = layers.Input(shape=[1,])
def conn(IP):
return IP[0]+IP[1]
out2 = layers.Lambda(conn)([y,z])
Tmodel = tf.keras.Model(inputs=[x,y,z], outputs=[out1,out2],name='Tmodel') # Define Model
Tmodel.summary()
# output
O1,O2 = Tmodel([2,15,10])
print(O1) # tf.Tensor(4, shape=(), dtype=int32)
print(O2) # tf.Tensor(25, shape=(), dtype=int32)