November 2018
Intermediate to advanced
322 pages
7h 54m
English
This model will consist of an embedding layer, followed by three layers of GRU and a fully connected layer with sigmoid activation. For the optimization and accuracy metric, we will use an Adam optimizer and binary_crossentropy, respectively:
def define_model(num_tokens,max_tokens): ''' Defines the model definition based on input parameters ''' model = Sequential() model.add(Embedding(input_dim=num_tokens, output_dim=EMBEDDING_SIZE, input_length=max_tokens, name='layer_embedding')) model.add(GRU(units=16, name = "gru_1",return_sequences=True)) model.add(GRU(units=8, name = "gru_2",return_sequences=True)) model.add(GRU(units=4, name= "gru_3")) model.add(Dense(1, activation='sigmoid',name="dense_1")) ...
Read now
Unlock full access