You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by jx...@apache.org on 2017/08/24 19:11:22 UTC
[incubator-mxnet] branch master updated: Added gen_data.py and
modified README.md for bi-lstm-sort example (#6549)
This is an automated email from the ASF dual-hosted git repository.
jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new 7f90a39 Added gen_data.py and modified README.md for bi-lstm-sort example (#6549)
7f90a39 is described below
commit 7f90a39c6d3e42cfb91946120a4f90797b3a06a0
Author: gurumurthys <gu...@gmail.com>
AuthorDate: Thu Aug 24 12:11:18 2017 -0700
Added gen_data.py and modified README.md for bi-lstm-sort example (#6549)
---
example/bi-lstm-sort/README.md | 6 +++++-
example/bi-lstm-sort/gen_data.py | 20 ++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/example/bi-lstm-sort/README.md b/example/bi-lstm-sort/README.md
index b56b671..a590a18 100644
--- a/example/bi-lstm-sort/README.md
+++ b/example/bi-lstm-sort/README.md
@@ -2,9 +2,13 @@ This is an example of using bidirection lstm to sort an array.
Firstly, generate data by:
- cd data
python gen_data.py
+Move generated txt files to data directory
+
+ mkdir data
+ mv *.txt data
+
Then, train the model by:
python lstm_sort.py
diff --git a/example/bi-lstm-sort/gen_data.py b/example/bi-lstm-sort/gen_data.py
new file mode 100644
index 0000000..55ce1cf
--- /dev/null
+++ b/example/bi-lstm-sort/gen_data.py
@@ -0,0 +1,20 @@
+import random
+
+vocab = [str(x) for x in range(100, 1000)]
+sw_train = open("sort.train.txt", "w")
+sw_test = open("sort.test.txt", "w")
+sw_valid = open("sort.valid.txt", "w")
+
+for i in range(1000000):
+ seq = " ".join([vocab[random.randint(0, len(vocab) - 1)] for j in range(5)])
+ k = i % 50
+ if k == 0:
+ sw_test.write(seq + "\n")
+ elif k == 1:
+ sw_valid.write(seq + "\n")
+ else:
+ sw_train.write(seq + "\n")
+
+sw_train.close()
+sw_test.close()
+sw_valid.close()
--
To stop receiving notification emails like this one, please contact
['"commits@mxnet.apache.org" <co...@mxnet.apache.org>'].