| 0 | 0 |
{
|
| 1 | |
"cells": [],
|
| 2 | |
"metadata": {},
|
|
1 |
"cells": [
|
|
2 |
{
|
|
3 |
"cell_type": "code",
|
|
4 |
"execution_count": 1,
|
|
5 |
"metadata": {},
|
|
6 |
"outputs": [
|
|
7 |
{
|
|
8 |
"name": "stderr",
|
|
9 |
"output_type": "stream",
|
|
10 |
"text": [
|
|
11 |
"/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
|
|
12 |
" _np_qint8 = np.dtype([(\"qint8\", np.int8, 1)])\n",
|
|
13 |
"/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
|
|
14 |
" _np_quint8 = np.dtype([(\"quint8\", np.uint8, 1)])\n",
|
|
15 |
"/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:528: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
|
|
16 |
" _np_qint16 = np.dtype([(\"qint16\", np.int16, 1)])\n",
|
|
17 |
"/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:529: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
|
|
18 |
" _np_quint16 = np.dtype([(\"quint16\", np.uint16, 1)])\n",
|
|
19 |
"/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:530: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
|
|
20 |
" _np_qint32 = np.dtype([(\"qint32\", np.int32, 1)])\n",
|
|
21 |
"/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:535: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
|
|
22 |
" np_resource = np.dtype([(\"resource\", np.ubyte, 1)])\n"
|
|
23 |
]
|
|
24 |
},
|
|
25 |
{
|
|
26 |
"name": "stdout",
|
|
27 |
"output_type": "stream",
|
|
28 |
"text": [
|
|
29 |
"11:40:51 INFO:best_model: ./results/output_poem/best_model/model-61170\n",
|
|
30 |
"\n",
|
|
31 |
"WARNING:tensorflow:From /home/jovyan/work/char_rnn_model.py:51: LSTMCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n",
|
|
32 |
"Instructions for updating:\n",
|
|
33 |
"This class is equivalent as tf.keras.layers.LSTMCell, and will be replaced by that in Tensorflow 2.0.\n",
|
|
34 |
"11:40:51 WARNING:From /home/jovyan/work/char_rnn_model.py:51: LSTMCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n",
|
|
35 |
"Instructions for updating:\n",
|
|
36 |
"This class is equivalent as tf.keras.layers.LSTMCell, and will be replaced by that in Tensorflow 2.0.\n",
|
|
37 |
"WARNING:tensorflow:From /home/jovyan/work/char_rnn_model.py:62: MultiRNNCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n",
|
|
38 |
"Instructions for updating:\n",
|
|
39 |
"This class is equivalent as tf.keras.layers.StackedRNNCells, and will be replaced by that in Tensorflow 2.0.\n",
|
|
40 |
"11:40:51 WARNING:From /home/jovyan/work/char_rnn_model.py:62: MultiRNNCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n",
|
|
41 |
"Instructions for updating:\n",
|
|
42 |
"This class is equivalent as tf.keras.layers.StackedRNNCells, and will be replaced by that in Tensorflow 2.0.\n",
|
|
43 |
"WARNING:tensorflow:From /usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n",
|
|
44 |
"Instructions for updating:\n",
|
|
45 |
"Colocations handled automatically by placer.\n",
|
|
46 |
"11:40:51 WARNING:From /usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n",
|
|
47 |
"Instructions for updating:\n",
|
|
48 |
"Colocations handled automatically by placer.\n",
|
|
49 |
"WARNING:tensorflow:From /home/jovyan/work/char_rnn_model.py:107: static_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version.\n",
|
|
50 |
"Instructions for updating:\n",
|
|
51 |
"Please use `keras.layers.RNN(cell, unroll=True)`, which is equivalent to this API\n",
|
|
52 |
"11:40:51 WARNING:From /home/jovyan/work/char_rnn_model.py:107: static_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version.\n",
|
|
53 |
"Instructions for updating:\n",
|
|
54 |
"Please use `keras.layers.RNN(cell, unroll=True)`, which is equivalent to this API\n",
|
|
55 |
"WARNING:tensorflow:From /usr/local/lib/python3.5/dist-packages/tensorflow/python/training/saver.py:1266: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.\n",
|
|
56 |
"Instructions for updating:\n",
|
|
57 |
"Use standard file APIs to check for files with this prefix.\n",
|
|
58 |
"11:40:51 WARNING:From /usr/local/lib/python3.5/dist-packages/tensorflow/python/training/saver.py:1266: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.\n",
|
|
59 |
"Instructions for updating:\n",
|
|
60 |
"Use standard file APIs to check for files with this prefix.\n"
|
|
61 |
]
|
|
62 |
}
|
|
63 |
],
|
|
64 |
"source": [
|
|
65 |
"from handler import handle"
|
|
66 |
]
|
|
67 |
},
|
|
68 |
{
|
|
69 |
"cell_type": "code",
|
|
70 |
"execution_count": 2,
|
|
71 |
"metadata": {},
|
|
72 |
"outputs": [],
|
|
73 |
"source": [
|
|
74 |
"conf = {'体裁':'五言', 'style':'藏头诗', 'Chinese_word':'一二三四'}\n",
|
|
75 |
"res = handle(conf)"
|
|
76 |
]
|
|
77 |
},
|
|
78 |
{
|
|
79 |
"cell_type": "code",
|
|
80 |
"execution_count": 3,
|
|
81 |
"metadata": {},
|
|
82 |
"outputs": [
|
|
83 |
{
|
|
84 |
"data": {
|
|
85 |
"text/plain": [
|
|
86 |
"{'Poetry': '一谈安信惭转真,\\n二毛吹血自在斯。\\n三年波澜恐不安,\\n四海无人不可知。\\n'}"
|
|
87 |
]
|
|
88 |
},
|
|
89 |
"execution_count": 3,
|
|
90 |
"metadata": {},
|
|
91 |
"output_type": "execute_result"
|
|
92 |
}
|
|
93 |
],
|
|
94 |
"source": [
|
|
95 |
"res"
|
|
96 |
]
|
|
97 |
},
|
|
98 |
{
|
|
99 |
"cell_type": "code",
|
|
100 |
"execution_count": 23,
|
|
101 |
"metadata": {},
|
|
102 |
"outputs": [],
|
|
103 |
"source": [
|
|
104 |
"res1 = res['Poetry'].split('。')[:2]"
|
|
105 |
]
|
|
106 |
},
|
|
107 |
{
|
|
108 |
"cell_type": "code",
|
|
109 |
"execution_count": 29,
|
|
110 |
"metadata": {},
|
|
111 |
"outputs": [],
|
|
112 |
"source": [
|
|
113 |
"res1 = res['Poetry'].split('。')[:2]\n",
|
|
114 |
"res2 = []\n",
|
|
115 |
"for i in res1:\n",
|
|
116 |
" res2.extend(i.split(','))\n",
|
|
117 |
"res3 = res2[0]+',\\n'+res2[1]+'。\\n'+res2[2]+',\\n'+res2[3]+'。'"
|
|
118 |
]
|
|
119 |
},
|
|
120 |
{
|
|
121 |
"cell_type": "code",
|
|
122 |
"execution_count": 30,
|
|
123 |
"metadata": {},
|
|
124 |
"outputs": [
|
|
125 |
{
|
|
126 |
"data": {
|
|
127 |
"text/plain": [
|
|
128 |
"['一闻江城涯', '二月月涛中', '三湘闇北内', '四海无人同']"
|
|
129 |
]
|
|
130 |
},
|
|
131 |
"execution_count": 30,
|
|
132 |
"metadata": {},
|
|
133 |
"output_type": "execute_result"
|
|
134 |
}
|
|
135 |
],
|
|
136 |
"source": [
|
|
137 |
"res2"
|
|
138 |
]
|
|
139 |
},
|
|
140 |
{
|
|
141 |
"cell_type": "code",
|
|
142 |
"execution_count": 35,
|
|
143 |
"metadata": {},
|
|
144 |
"outputs": [
|
|
145 |
{
|
|
146 |
"name": "stdout",
|
|
147 |
"output_type": "stream",
|
|
148 |
"text": [
|
|
149 |
"一闻江城涯,\n",
|
|
150 |
"二月月涛中。\n",
|
|
151 |
"三湘闇北内,\n",
|
|
152 |
"四海无人同。\n"
|
|
153 |
]
|
|
154 |
}
|
|
155 |
],
|
|
156 |
"source": [
|
|
157 |
"res3 = res2[0]+',\\n'+res2[1]+'。\\n'+res2[2]+',\\n'+res2[3]+'。'\n",
|
|
158 |
"print(res3)"
|
|
159 |
]
|
|
160 |
},
|
|
161 |
{
|
|
162 |
"cell_type": "code",
|
|
163 |
"execution_count": 1,
|
|
164 |
"metadata": {},
|
|
165 |
"outputs": [],
|
|
166 |
"source": [
|
|
167 |
"# You can use other public modules via our Client object with module's identifier\n",
|
|
168 |
"# and parameters.\n",
|
|
169 |
"# For more detailes, please see our online document - https://momodel.github.io/docs/#\n",
|
|
170 |
"\n",
|
|
171 |
"import os\n",
|
|
172 |
"import sys\n",
|
|
173 |
"\n",
|
|
174 |
"# Define root path\n",
|
|
175 |
"sys.path.append('../')\n",
|
|
176 |
"\n",
|
|
177 |
"# Import necessary packages\n",
|
|
178 |
"from modules import json_parser\n",
|
|
179 |
"from modules import Client\n",
|
|
180 |
"\n",
|
|
181 |
"# Initialise Client object\n",
|
|
182 |
"client = Client(api_key='33799e1c5d6fa05fdd7dec3aa7aad868445d1c737edcf9c37fa89cb3b39cb2d9',\n",
|
|
183 |
" project_id='5bfd118f1afd942b66b36b30', user_ID='yangsaisai',\n",
|
|
184 |
" project_type='app', source_file_path='Untitled.ipynb')\n",
|
|
185 |
"\n",
|
|
186 |
"# Make run/train/predict command alias for further use\n",
|
|
187 |
"run = client.run\n",
|
|
188 |
"train = client.train\n",
|
|
189 |
"predict = client.predict\n",
|
|
190 |
"\n",
|
|
191 |
"# Make controller alias for further use\n",
|
|
192 |
"controller = client.controller\n",
|
|
193 |
"\n"
|
|
194 |
]
|
|
195 |
},
|
|
196 |
{
|
|
197 |
"cell_type": "code",
|
|
198 |
"execution_count": 2,
|
|
199 |
"metadata": {},
|
|
200 |
"outputs": [
|
|
201 |
{
|
|
202 |
"name": "stdout",
|
|
203 |
"output_type": "stream",
|
|
204 |
"text": [
|
|
205 |
"OVERVIEW.md poems_edge_split.txt rhyme_words.txt\n",
|
|
206 |
"poem_ids.txt \u001b[0m\u001b[01;34mresults\u001b[0m/ vectors_poem.bin\n"
|
|
207 |
]
|
|
208 |
}
|
|
209 |
],
|
|
210 |
"source": [
|
|
211 |
"ls /home/jovyan/work/datasets/yangsaisai-poetrydatasets"
|
|
212 |
]
|
|
213 |
},
|
|
214 |
{
|
|
215 |
"cell_type": "code",
|
|
216 |
"execution_count": null,
|
|
217 |
"metadata": {},
|
|
218 |
"outputs": [],
|
|
219 |
"source": []
|
|
220 |
}
|
|
221 |
],
|
|
222 |
"metadata": {
|
|
223 |
"kernelspec": {
|
|
224 |
"display_name": "Python 3",
|
|
225 |
"language": "python",
|
|
226 |
"name": "python3"
|
|
227 |
},
|
|
228 |
"language_info": {
|
|
229 |
"codemirror_mode": {
|
|
230 |
"name": "ipython",
|
|
231 |
"version": 3
|
|
232 |
},
|
|
233 |
"file_extension": ".py",
|
|
234 |
"mimetype": "text/x-python",
|
|
235 |
"name": "python",
|
|
236 |
"nbconvert_exporter": "python",
|
|
237 |
"pygments_lexer": "ipython3",
|
|
238 |
"version": "3.5.2"
|
|
239 |
}
|
|
240 |
},
|
| 3 | 241 |
"nbformat": 4,
|
| 4 | 242 |
"nbformat_minor": 2
|
| 5 | 243 |
}
|