From e7ddfe8ffef521126f3d02545703289b736c3e5c Mon Sep 17 00:00:00 2001 From: Matthias Planitzer Date: Sat, 11 Aug 2018 14:59:01 +0200 Subject: [PATCH] Bugfix: Sorted character list Fixed a bug where the character list generated upon data loading would return different ordered results every time it's called resulting in non-reproducible behaviour. This leads to the generation of scrambled text when loading saved weights. Instead, sorted the list alphabetically to ensure consistent results. --- RNN_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RNN_utils.py b/RNN_utils.py index abba2ca..e85e57c 100644 --- a/RNN_utils.py +++ b/RNN_utils.py @@ -18,7 +18,7 @@ def generate_text(model, length, vocab_size, ix_to_char): # method for preparing the training data def load_data(data_dir, seq_length): data = open(data_dir, 'r').read() - chars = list(set(data)) + chars = sorted(set(data)) VOCAB_SIZE = len(chars) print('Data length: {} characters'.format(len(data)))