# no attribute '_inbound_nodes' error even when using Lambda layer in Keras [closed]

I have a (28,000 x 300) dimension matrix, let's call it label_embedding, which I want to do a dot product with the bottleneck layer of my model. I have created an architecture which gives a (batch_size x 300) at its bottleneck layer.

I am using a generator function for input. The label_embedding matrix is taken as input in the following way:

inp7 = Input(tensor=labels_embeddings)


And for the dot product I am doing the following:

out = Lambda(dot_)([x1, K.transpose(inp7)])


where x1 is the bottleneck layer and dot_ is:

def dot_(tensors):
return K.dot(tensors[0], tensors[1])


The problem is that even though the shape of the out variable is correct, that is, (batch_size x 28000), I get the following error:

AttributeError: 'NoneType' object has no attribute '_inbound_nodes' P.S.: I am using tensorflow and keras

P.S.: I have been using keras layers until the out variable where I use keras backend as K

## 1 Answer

Okay, I solved the problem. So all backend based functions need to be wrapped within the lambda layer. So instead of:

out = Lambda(dot_)([x1, K.transpose(inp7)])


and

def dot_(tensors):
return K.dot(tensors[0], tensors[1])


I wrote:

out = Lambda(dot_)([x1, inp7])


and

def dot_(tensors):
return K.dot(tensors[0], K.transpose(tensors[1]))