|
96 | 96 | "#--- --- ---- --- ---- --- ---- ---- --- ----- ---- ---\n",
|
97 | 97 | "# -- Write Files ---- ---- ---- --- ---- --- --- --- -- \n",
|
98 | 98 | "#--- --- ---- --- ---- --- ---- ---- --- ----- ---- ---\n",
|
99 |
| - "def writeFiles(model, modelName, history_callback, modelList, seq_length, total_sequences, epochs, batch_size):\n", |
| 99 | + "def writeFiles(model, modelName, history_callback, modelList, seq_length, total_sequences, epochs, batch_size, results_path):\n", |
100 | 100 | " loss_history = history_callback.history\n",
|
101 | 101 | " \n",
|
102 | 102 | " # save the model to file\n",
|
103 |
| - " model.save('m_' + modelName + '.h5')\n", |
| 103 | + " model.save(results_path.rstrip('/') + '/m_' + modelName + '.h5')\n", |
104 | 104 | " loss_history['seq_length'] = seq_length\n",
|
105 | 105 | " loss_history['total_sequences'] = total_sequences\n",
|
106 | 106 | " loss_history['batch_size'] = batch_size\n",
|
107 | 107 | " loss_history['epochs'] = epochs\n",
|
108 | 108 | " \n",
|
109 | 109 | " # save losses\n",
|
110 |
| - " with open('info_' + modelName + '.txt', 'w+') as f:\n", |
| 110 | + " with open(results_path.rstrip('/') + '/info_' + modelName + '.txt', 'w+') as f:\n", |
111 | 111 | " f.write(str(modelList))\n",
|
112 | 112 | " f.write('\\n')\n",
|
113 | 113 | " f.write(str(loss_history))\n"
|
|
219 | 219 | },
|
220 | 220 | {
|
221 | 221 | "cell_type": "code",
|
222 |
| - "execution_count": 8, |
| 222 | + "execution_count": 14, |
223 | 223 | "metadata": {},
|
224 |
| - "outputs": [ |
225 |
| - { |
226 |
| - "ename": "SyntaxError", |
227 |
| - "evalue": "positional argument follows keyword argument (<ipython-input-8-b8a592ace547>, line 61)", |
228 |
| - "output_type": "error", |
229 |
| - "traceback": [ |
230 |
| - "\u001b[0;36m File \u001b[0;32m\"<ipython-input-8-b8a592ace547>\"\u001b[0;36m, line \u001b[0;32m61\u001b[0m\n\u001b[0;31m writeFiles(model, modelName, history_callback, modelList, seq_length, total_sequences = len(sequences), epochs, batch_size)\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m positional argument follows keyword argument\n" |
231 |
| - ] |
232 |
| - } |
233 |
| - ], |
| 224 | + "outputs": [], |
234 | 225 | "source": [
|
235 |
| - "def trainModelComplete():\n", |
| 226 | + "def trainModelComplete(results_path):\n", |
236 | 227 | " from keras.utils import to_categorical\n",
|
237 | 228 | " \n",
|
238 | 229 | " #--- PARAMETERS --- --- --- ---- --- --- ---- ---- --- ----- --- --- ----\n",
|
|
299 | 290 | " #-- Fit model -- ---- --- --- --- ---- --- --- ---- --- --- --- --- --- --- --- --- \n",
|
300 | 291 | " history_callback = modelFit(model, modelName, X, y, seq_length, batch_size, epochs)\n",
|
301 | 292 | " #-- Save history and final model --- -\n",
|
302 |
| - " writeFiles(model, modelName, history_callback, modelList, seq_length, len(sequences), epochs, batch_size)" |
| 293 | + " writeFiles(model, modelName, history_callback, modelList, seq_length, len(sequences), epochs, batch_size, results_path)" |
303 | 294 | ]
|
304 | 295 | },
|
305 | 296 | {
|
|
0 commit comments