Try to search your question here, if you can't find : Ask Any Question Now ?

Keras throws `'Tensor' object has no attribute '_keras_shape'` when splitting a layer output

HomeCategory: stackoverflowKeras throws `'Tensor' object has no attribute '_keras_shape'` when splitting a layer output
Avatarbhawya asked 2 years ago

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 product.

x = MaxPooling2D(pool_size=(1,MAX_SEQUENCE_LENGTH),strides=(1,1))(x)
x_A = Reshape((1,EMBEDDING_DIM))(x[:,0])
x_B = Reshape((1,EMBEDDING_DIM))(x[:,1])

diff = keras.layers.Subtract()([x_A, x_B])
prod = keras.layers.Multiply()([x_A, x_B])


nn = keras.layers.Concatenate()([diff, prod])

Currently, when I do x[:,0] it throws an error saying AttributeError: 'Tensor' object has no attribute '_keras_shape'. I assume the result of splitting of tensor object is a tensor object that doesn’t have _keras_shape.

Can someone help me solve this? Thanks.

1 Answers
Best Answer
Avatarbhawya answered 2 years ago
Your Answer

8 + 11 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com