Keras Throws `'tensor' Object Has No Attribute '_keras_shape'` When Splitting A Layer Output
I have sentence embedding output X of a sentence pair of dimension 2*1*300. I want to split this output into two vectors of shape 1*300 to calculate its absolute difference and pr
Solution 1:
Keras adds some info to tensors when they're processed in layers. Since you're splitting the tensor outside layers, it loses that info.
The solution involves returning the split tensors from Lambda layers:
x_A = Lambda(lambda x: x[:,0], output_shape=notNecessaryWithTensorflow)(x)
x_B = Lambda(lambda x: x[:,1], output_shape=notNecessaryWithTensorflow)(x)
x_A = Reshape((1,EMBEDDING_DIM))(x_A)
x_B = Reshape((1,EMBEDDING_DIM))(x_B)
Post a Comment for "Keras Throws `'tensor' Object Has No Attribute '_keras_shape'` When Splitting A Layer Output"