<jupyter_start><jupyter_text>It surprises me that I am getting about 70% accuracy - especially when the embedding layer retains the order of the sequence and does not just say which words appear there and which do not as in the original example.<jupyter_code>model_small = build_model(
    kl.Embedding(DICTIONARY_SIZE, 32, input_length=MAX_SEQUENCE_LENGTH),
    kl.GRU(8, return_sequences=False),
    kl.Dense(46, activation='softmax'),
    verbose=1
)

history_small = model_small.fit(
    train_data,
    train_labels,
    epochs=20,
    batch_size=64,
    validation_split=0.2
)

plot_history(history_small)
model_medium = build_model(
    kl.Embedding(DICTIONARY_SIZE, 32, input_length=MAX_SEQUENCE_LENGTH),
    kl.GRU(64, return_sequences=False),
    kl.Dense(46, activation='softmax'),
    verbose=1
)

history_medium = model_medium.fit(
    train_data,
    train_labels,
    epochs=40,
    batch_size=64,
    validation_split=0.2
)

plot_history(history_medium)
model_big = build_model(
    kl.Embedding(DICTIONARY_SIZE, 32, input_length=MAX_SEQUENCE_LENGTH),
    kl.GRU(MAX_SEQUENCE_LENGTH, return_sequences=False),
    kl.Dense(46, activation='softmax'),
    verbose=1
)

history_big = model_big.fit(
    train_data,
    train_labels,
    epochs=60,
    batch_size=64,
    validation_split=0.2
)

plot_history(history_big)
model_hopeful = build_model(
    kl.Embedding(DICTIONARY_SIZE, 32, input_length=MAX_SEQUENCE_LENGTH),
    kl.GRU(MAX_SEQUENCE_LENGTH, return_sequences=True,  dropout=0.18, recurrent_dropout=0.18),
    kl.GRU(MAX_SEQUENCE_LENGTH, return_sequences=True,  dropout=0.18, recurrent_dropout=0.18),
    kl.GRU(MAX_SEQUENCE_LENGTH, return_sequences=False, dropout=0.18, recurrent_dropout=0.18),
    kl.Dropout(0.2),
    kl.Dense(MAX_SEQUENCE_LENGTH // 2, activation='relu'),
    kl.Dense(46, activation='softmax'),
    verbose=1
)

# I am running this over-night so I just put a bit more epochs there...
history_hopeful = model_hopeful.fit(
    train_data,
    train_labels,
    epochs=100,
    batch_size=64,
    validation_data=(test_data, test_labels)
)

plot_history(history_hopeful)<jupyter_output>Model summary:
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
embedding_5 (Embedding)      (None, 250, 32)           128000    
_________________________________________________________________
gru_4 (GRU)                  (None, 250, 250)          212250    
_________________________________________________________________
gru_5 (GRU)                  (None, 250, 250)          375750    
_________________________________________________________________
gru_6 (GRU)                  (None, 250)               375750    
_________________________________________________________________
dropout_1 (Dropout)          (None, 250)               0         
_________________________________________________________________
dense_8 (Dense)              (None, 125)               31375     
_____________________________________________________________[...]
{'fraction_non_alphanumeric': 0.1040536227258219, 'fraction_numerical': 0.041812958825406955, 'mean_word_length': 3.9984051036682615, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '285514', 'license': 'MIT', 'n_tokens_mistral': 1017, 'n_tokens_neox': 908, 'n_words': 178, 'path': 'Intro_to_Deep_Learning/session06/Reuters_Newswire_Classification-Roznovjak.ipynb', 'repo_name': 'rozni/uni-ml', 'size': '3133'}