Login using Social Account
     Continue with GoogleLogin using your credentials
Now that we have preprocessed and created the dataset, we can create the model:
Note:
keras.layers.Embedding
: Turns positive integers (indexes) into dense vectors of fixed size. More here.keras.layers.GRU
: The GRU(Gated Recurrent Unit) Layer.Set embed_size
to 128
, which is the embedding size of each word.
embed_size = 128
Create the model model
with
Embedding layer
GRU layer with 4 units
GRU layer with 2 units
Dense layer with 1 unit and sigmoid
activation
model = keras.models.Sequential([
keras.layers.Embedding(vocab_size + num_oov_buckets, embed_size,
mask_zero=True,
input_shape=[None]),
keras.layers.GRU(4, return_sequences=True),
keras.layers.GRU(2),
keras.layers.Dense(1, activation="sigmoid")
])
Compile the model with "binary_crossentropy"
loss(as this is a binary classification problem), "adam"
optimizer and "accuracy"
metric.
model.compile(loss="binary_crossentropy", optimizer="adam", metrics=["accuracy"])
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...