This is an automated email from the ASF dual-hosted git repository.

joern pushed a commit to branch namecat_shuffle
in repository https://gitbox.apache.org/repos/asf/opennlp-sandbox.git

commit 4d63911591c268e1ccabd0bd40390d6fdbd726d8
Author: Jörn Kottmann <[email protected]>
AuthorDate: Wed Apr 3 10:38:10 2019 +0200

    Shuffle the training samples for each epoch in namecat
---
 tf-ner-poc/src/main/python/namecat/namecat.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tf-ner-poc/src/main/python/namecat/namecat.py 
b/tf-ner-poc/src/main/python/namecat/namecat.py
index 86822c0..cc3f28a 100644
--- a/tf-ner-poc/src/main/python/namecat/namecat.py
+++ b/tf-ner-poc/src/main/python/namecat/namecat.py
@@ -169,7 +169,11 @@ def main():
             acc_train = []
 
             batch_indexes = list(range(floor(len(names_train) / batch_size)))
-            random.Random(epoch).shuffle(batch_indexes)
+
+            # Shuffle the data
+            combined = list(zip(names_train, labels_train))
+            random.shuffle(combined)
+            names_train[:], labels_train[:] = zip(*combined)
 
             for batch_index in batch_indexes:
                 label_train_batch, name_train_batch, name_train_length = \

Reply via email to