Skip to content

Add Fixed Features With Word Embeddings  #2190

@BrianMiner

Description

@BrianMiner

I am wondering if it is possible to add fixed features to an RNN with word embedding in Keras? I have two inputs which share the same word embedding (and this model works) and I would like to see if it is possible to mix in fixed features which describe further the contexts of the example. The use case is a query and a returned title page as the word embeddings and the fixed features are things like the length of each, various similarity measures of each etc).

model_query = Sequential()  

    #creates a matrix that is 30,046 x 400  (number of distinct words x 400)
model_query.add(Embedding(output_dim=dimsize,
                        input_dim=n_symbols,
                        mask_zero=True,
                        weights=[embedding_weights],
                        input_length=input_length))  

model_title = Sequential()  # or Graph or whatever
model_title.add(Embedding(output_dim=dimsize,
                        input_dim=n_symbols,
                        mask_zero=True,
                        weights=[embedding_weights],
                        input_length=input_length))  


model_features=Sequential()
model_features.add(????)  **  #How to add other features??????**

model = Sequential()
model.add(Merge([model_query, model_title], mode='concat'))  #Add them here????

model.add(LSTM(400))
model.add(Dropout(0.5))

model.add(Dense(1))
print ("Compiling Model....")
model.compile(loss='mean_squared_error', optimizer='rmsprop')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions