Skip to content

Commit b7cfaf6

Browse files
authored
Merge pull request #44 from oujago/develop
version 0.4.0
2 parents a24734e + 1a6e258 commit b7cfaf6

23 files changed

+571
-245
lines changed

CHANGES.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@ Changelog
22
---------
33

44

5+
0.4.0 (2017.-06-18)
6+
~~~~~~~~~~~~~~~~~~~
7+
8+
Version 0.4.0.
9+
10+
* Embedding backward
11+
* Momentum
12+
* NesterovMomentum
13+
* Adagrad
14+
* RMSprop
15+
* Adadelta
16+
* Adam
17+
* Adamax
18+
19+
20+
521
0.3.0 (2017-06-15)
622
~~~~~~~~~~~~~~~~~~
723

MANIFEST.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ include requirements-dev.txt
1010
recursive-include tests *.py
1111

1212
# examples
13-
recursive-include examples *.py
13+
recursive-include examples *.py *.txt *.label
1414

1515
# documents
16-
recursive-include docs *.rst conf.py *.css Makefile
16+
recursive-include docs *.rst *.py fix_rtd.css Makefile make.bat
1717

1818
# applications
1919
recursive-include application *.py *.md *.html *.jpg

README.rst

Lines changed: 67 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,13 @@
2222

2323
.. https://codeclimate.com/github/oujago/NumpyDL/badges/gpa.svg
2424
:target: https://codeclimate.com/github/oujago/NumpyDL
25-
:alt: Code Climate
2625
2726
.. image:: https://codeclimate.com/github/oujago/NumpyDL/badges/issue_count.svg
2827
:target: https://codeclimate.com/github/oujago/NumpyDL
29-
:alt: Issue Count
3028

3129
.. image:: https://img.shields.io/github/issues/oujago/NumpyDL.svg
3230
:target: https://github.com/oujago/NumpyDL
3331

34-
.. image:: https://img.shields.io/github/forks/oujago/NumpyDL.svg
35-
:target: https://github.com/oujago/NumpyDL
36-
37-
.. image:: https://img.shields.io/github/stars/oujago/NumpyDL.svg
38-
:target: https://github.com/oujago/NumpyDL
39-
4032
.. image:: https://zenodo.org/badge/83100910.svg
4133
:target: https://zenodo.org/badge/latestdoi/83100910
4234

@@ -67,6 +59,7 @@ Its main features are:
6759
5. *API* like ``Keras`` library
6860
6. *Examples* for several AI tasks
6961
7. *Application* for a toy chatbot
62+
8. *Mobile friendly* documents
7063

7164

7265
Documentation
@@ -105,19 +98,17 @@ Examples
10598
``NumpyDL`` provides several examples of AI tasks:
10699

107100
* sentence classification
108-
* LSTM in `examples/lstm_sentence_classification.py`
109-
* CNN in `examples/cnn_sentence_classification.py`
101+
* LSTM in *examples/lstm_sentence_classification.py*
102+
* CNN in *examples/cnn_sentence_classification.py*
110103
* mnist handwritten recognition
111-
* MLP in `examples/mlp-mnist.py`
112-
* MLP in `examples/mlp-digits.py`
113-
* CNN in `examples/cnn-minist.py`
104+
* MLP in *examples/mlp-mnist.py*
105+
* MLP in *examples/mlp-digits.py*
106+
* CNN in *examples/cnn-minist.py*
114107
* language modeling
115-
* RNN in `examples/rnn-character-lm.py`
116-
* RNN in `examples/rnn-character-lm2.py`
117-
* LSTM in `examples/lstm-character-lm.py`
118-
* LSTM in `examples/lstm-character-lm2.py`
108+
* RNN in *examples/rnn-character-lm.py*
109+
* LSTM in *examples/lstm-character-lm.py*
119110

120-
One concrete code example in `examples/mlp-digits.py`:
111+
One concrete code example in *examples/mlp-digits.py*:
121112

122113
.. code-block:: python
123114
@@ -152,11 +143,68 @@ Applications
152143
``NumpyDL`` provides one toy application:
153144

154145
* Chatbot
155-
* seq2seq in `applications/chatbot/model.py`
146+
* seq2seq in *applications/chatbot/model.py*
156147

157148

158149
And its final result:
159150

160151
.. figure:: applications/chatbot/pics/chatbot.png
161152
:width: 80%
162153

154+
155+
Supports
156+
========
157+
158+
``NumpyDL`` supports following deep learning techniques:
159+
160+
* Layers
161+
* Linear
162+
* Dense
163+
* Softmax
164+
* Dropout
165+
* Convolution
166+
* Embedding
167+
* BatchNormal
168+
* MeanPooling
169+
* MaxPooling
170+
* SimpleRNN
171+
* GRU
172+
* LSTM
173+
* Flatten
174+
* DimShuffle
175+
* Optimizers
176+
* SGD
177+
* Momentum
178+
* NesterovMomentum
179+
* Adagrad
180+
* RMSprop
181+
* Adadelta
182+
* Adam
183+
* Adamax
184+
* Objectives
185+
* MeanSquaredError
186+
* HellingerDistance
187+
* BinaryCrossEntropy
188+
* SoftmaxCategoricalCrossEntropy
189+
* Initializations
190+
* Zero
191+
* One
192+
* Uniform
193+
* Normal
194+
* LecunUniform
195+
* GlorotUniform
196+
* GlorotNormal
197+
* HeNormal
198+
* HeUniform
199+
* Orthogonal
200+
* Activations
201+
* Sigmoid
202+
* Tanh
203+
* ReLU
204+
* Linear
205+
* Softmax
206+
* Elliot
207+
* SymmetricElliot
208+
* SoftPlus
209+
* SoftSign
210+

applications/chatbot/main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def ask():
2424
if message == "quit":
2525
exit()
2626
else:
27-
# print bot_response
2827
return jsonify({'status': 'OK',
2928
'answer': model.utter(message)})
3029

examples/lstm-character-lm.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
import npdl
88

99

10-
def main(max_iter, corpus_path=os.path.join(os.path.dirname(__file__), 'data/lm/tiny_shakespeare.txt')):
10+
def get_data():
11+
corpus_path = os.path.join(os.path.dirname(__file__), 'data/lm/tiny_shakespeare.txt')
12+
1113
raw_text = open(corpus_path, 'r').read()
1214
chars = list(set(raw_text))
1315
data_size, vocab_size = len(raw_text), len(chars)
@@ -16,7 +18,6 @@ def main(max_iter, corpus_path=os.path.join(os.path.dirname(__file__), 'data/lm/
1618
index_to_char = {i: ch for i, ch in enumerate(chars)}
1719

1820
time_steps, batch_size = 30, 40
19-
2021
length = batch_size * 20
2122
text_pointers = np.random.randint(data_size - time_steps - 1, size=length)
2223
batch_in = np.zeros([length, time_steps, vocab_size])
@@ -26,6 +27,12 @@ def main(max_iter, corpus_path=os.path.join(os.path.dirname(__file__), 'data/lm/
2627
batch_in[i, range(time_steps), b_[:-1]] = 1
2728
batch_out[i, b_[-1]] = 1
2829

30+
return batch_size, vocab_size, time_steps, batch_in, batch_out
31+
32+
33+
def main1(max_iter):
34+
batch_size, vocab_size, time_steps, batch_in, batch_out = get_data()
35+
2936
print("Building model ...")
3037
net = npdl.Model()
3138
net.add(npdl.layers.BatchLSTM(n_out=300, n_in=vocab_size, return_sequence=True,
@@ -39,5 +46,21 @@ def main(max_iter, corpus_path=os.path.join(os.path.dirname(__file__), 'data/lm/
3946
net.fit(batch_in, batch_out, max_iter=max_iter, batch_size=batch_size)
4047

4148

49+
def main2(max_iter):
50+
batch_size, vocab_size, time_steps, batch_in, batch_out = get_data()
51+
52+
print("Building model ...")
53+
net = npdl.Model()
54+
net.add(npdl.layers.BatchLSTM(n_out=300, n_in=vocab_size, return_sequence=False,
55+
nb_batch=batch_size, nb_seq=time_steps))
56+
# net.add(npdl.layers.MeanPooling(pool_size=(time_steps, 1)))
57+
# net.add(npdl.layers.Flatten())
58+
net.add(npdl.layers.Softmax(n_out=vocab_size))
59+
net.compile(loss=npdl.objectives.SCCE(), optimizer=npdl.optimizers.SGD(lr=0.00001, clip=5))
60+
61+
print("Train model ...")
62+
net.fit(batch_in, batch_out, max_iter=max_iter, batch_size=batch_size)
63+
64+
4265
if __name__ == '__main__':
43-
main(100)
66+
main1(100)

examples/lstm-character-lm2.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

examples/lstm_sentence_classification.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,24 @@ def main(max_iter):
6262
net.fit(xs, ys, batch_size=nb_batch, validation_split=0.1, max_iter=max_iter)
6363

6464

65+
def main2(max_iter):
66+
nb_batch = 30
67+
nb_seq = 20
68+
69+
xs, ys, x_size, y_size = prepare_data(nb_seq)
70+
71+
net = npdl.Model()
72+
net.add(npdl.layers.Embedding(nb_batch=nb_batch, nb_seq=nb_seq,
73+
n_out=200, input_size=x_size,
74+
static=False))
75+
net.add(npdl.layers.BatchLSTM(n_out=400, return_sequence=True))
76+
net.add(npdl.layers.BatchLSTM(n_out=200, return_sequence=True))
77+
net.add(npdl.layers.MeanPooling((nb_seq, 1)))
78+
net.add(npdl.layers.Flatten())
79+
net.add(npdl.layers.Softmax(n_out=y_size))
80+
net.compile(loss='scce', optimizer=npdl.optimizers.RMSprop())
81+
net.fit(xs, ys, batch_size=nb_batch, validation_split=0.1, max_iter=max_iter)
82+
83+
6584
if __name__ == '__main__':
66-
main(100)
85+
main2(100)

0 commit comments

Comments
 (0)