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 is fed in as an input to the function, connection(x,k). Now, when I try to call the function in the Functional API, I tried using:
k = 5
y = Lambda(connection)(x)
Also,
y = Lambda(connection)(x,k)
But neither of those approaches worked. How can I feed in the value of k without assigning it as a global parameter?
kupdates through the model. The value ofkchanges for different times I call theLambdalayer. But I found the solution here, in a Keras GitHub Issue. Usingy = Lambda(connection, arguments={'k':k})(x)worked!