|
40 | 40 | "\n", |
41 | 41 | "# enable more output from conifer\n", |
42 | 42 | "import logging\n", |
| 43 | + "\n", |
43 | 44 | "logging.basicConfig(stream=sys.stdout, level=logging.WARNING)\n", |
44 | 45 | "logger = logging.getLogger('conifer')\n", |
45 | 46 | "logger.setLevel('DEBUG')\n", |
|
112 | 113 | "metadata": {}, |
113 | 114 | "outputs": [], |
114 | 115 | "source": [ |
115 | | - "clf = xgb.XGBClassifier(n_estimators=25, max_depth=5, learning_rate=1.0,\n", |
116 | | - " random_state=seed).fit(X_train_val, y_train_val)" |
| 116 | + "clf = xgb.XGBClassifier(n_estimators=25, max_depth=5, learning_rate=1.0, random_state=seed).fit(X_train_val, y_train_val)" |
117 | 117 | ] |
118 | 118 | }, |
119 | 119 | { |
|
150 | 150 | "# add a legend\n", |
151 | 151 | "from matplotlib.lines import Line2D\n", |
152 | 152 | "\n", |
153 | | - "lines = [Line2D([0], [0], ls='--'), Line2D([0], [0], ls='-'),]\n", |
| 153 | + "lines = [\n", |
| 154 | + " Line2D([0], [0], ls='--'),\n", |
| 155 | + " Line2D([0], [0], ls='-'),\n", |
| 156 | + "]\n", |
154 | 157 | "from matplotlib.legend import Legend\n", |
155 | 158 | "\n", |
156 | 159 | "leg = Legend(ax, lines, labels=['part1 Keras', 'xgboost'], loc='lower right', frameon=False)\n", |
|
222 | 225 | "# print the help to see the API on the conifer_model\n", |
223 | 226 | "help(conifer_model)\n", |
224 | 227 | "# write the project (writing HLS project to disk)\n", |
225 | | - "conifer_model.write() \n", |
| 228 | + "conifer_model.write()\n", |
226 | 229 | "# save the conifer model - we can load this again later\n", |
227 | 230 | "clf.save_model('model_5/xgboost_model.json')" |
228 | 231 | ] |
|
301 | 304 | "metadata": {}, |
302 | 305 | "outputs": [], |
303 | 306 | "source": [ |
304 | | - "y_hls_proba = softmax(y_hls) # compute class probabilities from the raw predictions\n", |
| 307 | + "y_hls_proba = softmax(y_hls) # compute class probabilities from the raw predictions\n", |
305 | 308 | "\n", |
306 | 309 | "print(f'Accuracy baseline: {accuracy_score(np.argmax(y_test_one_hot, axis=1), np.argmax(y_ref, axis=1)):.5f}')\n", |
307 | 310 | "print(f'Accuracy xgboost: {accuracy_score(np.argmax(y_test_one_hot, axis=1), np.argmax(y_xgb, axis=1)):.5f}')\n", |
|
318 | 321 | "# add a legend\n", |
319 | 322 | "from matplotlib.lines import Line2D\n", |
320 | 323 | "\n", |
321 | | - "lines = [Line2D([0], [0], ls='--'), Line2D([0], [0], ls=':'), Line2D([0], [0], ls='-'),]\n", |
| 324 | + "lines = [\n", |
| 325 | + " Line2D([0], [0], ls='--'),\n", |
| 326 | + " Line2D([0], [0], ls=':'),\n", |
| 327 | + " Line2D([0], [0], ls='-'),\n", |
| 328 | + "]\n", |
322 | 329 | "from matplotlib.legend import Legend\n", |
323 | 330 | "\n", |
324 | 331 | "leg = Legend(ax, lines, labels=['part1 Keras', 'xgboost', 'conifer'], loc='lower right', frameon=False)\n", |
|
390 | 397 | "outputs": [], |
391 | 398 | "source": [ |
392 | 399 | "pynq_model_cfg = conifer.backends.xilinxhls.auto_config()\n", |
393 | | - "pynq_model_cfg['OutputDir'] = 'model_5_pynq' # choose a new project directory\n", |
| 400 | + "pynq_model_cfg['OutputDir'] = 'model_5_pynq' # choose a new project directory\n", |
394 | 401 | "pynq_model_cfg['ProjectName'] = 'conifer_jettag'\n", |
395 | | - "pynq_model_cfg['AcceleratorConfig'] = {'Board' : 'pynq-z2', # choose a pynq-z2 board\n", |
396 | | - " 'InterfaceType' : 'float' # floating point for the data I/O (this is default)\n", |
397 | | - " }\n", |
| 402 | + "pynq_model_cfg['AcceleratorConfig'] = {\n", |
| 403 | + " 'Board': 'pynq-z2', # choose a pynq-z2 board\n", |
| 404 | + " 'InterfaceType': 'float', # floating point for the data I/O (this is default)\n", |
| 405 | + "}\n", |
398 | 406 | "\n", |
399 | 407 | "# print the config\n", |
400 | 408 | "print('Modified Configuration\\n' + '-' * 50)\n", |
|
0 commit comments