Wednesday, 24 November 2021

connect embedding layer with dimension (3,50) to lstm

how to connect embedding layer with dimension (3,50) to lstm?

array (3, 50) is fed to input "layer_i_emb" where three time steps with arrays of length 50 are stored in which product identifiers are stored

I tried to connect it before reshape and it didn't work either. embedding adds dimension and lstm does not take extra dimension. it's scary that you have to translate tensors into tf and manually work with tensors.

layer_i_inp = Input(shape = (3,50), name = 'item')
layer_i_emb = Embedding(output_dim = EMBEDDING_DIM*2,
                        input_dim = us_it_count[0]+1,
                        input_length = (3,50),
                        name = 'item_embedding')(layer_i_inp) 

layer_i_emb = Reshape([3,50, EMBEDDING_DIM*2])(layer_i_emb)

layer_i_emb = LSTM(MAX_FEATURES, dropout = 0.4, recurrent_dropout = 0.4, return_sequences = True)(layer_i_emb)
layer_i_emb = LSTM(MAX_FEATURES, dropout = 0.4, recurrent_dropout = 0.4, return_sequences = True)(layer_i_emb)
layer_i_emb = LSTM(MAX_FEATURES, dropout = 0.4, recurrent_dropout = 0.4)(layer_i_emb)

layer_i_emb = Flatten()(layer_i_emb)


from connect embedding layer with dimension (3,50) to lstm

No comments:

Post a Comment