Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit hooks
Browse files Browse the repository at this point in the history
pre-commit-ci[bot] committed Sep 26, 2024
1 parent a3ab35f commit 331465f
Showing 3 changed files with 24 additions and 13 deletions.
1 change: 0 additions & 1 deletion docker/vitis_cfg.txt
Original file line number Diff line number Diff line change
@@ -30,4 +30,3 @@ CreateFileAssociation=1

# Choose whether disk usage will be optimized (reduced) after installation
EnableDiskUsageOptimization=1

28 changes: 18 additions & 10 deletions part5_bdt.ipynb
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@
"\n",
"# enable more output from conifer\n",
"import logging\n",
"\n",
"logging.basicConfig(stream=sys.stdout, level=logging.WARNING)\n",
"logger = logging.getLogger('conifer')\n",
"logger.setLevel('DEBUG')\n",
@@ -112,8 +113,7 @@
"metadata": {},
"outputs": [],
"source": [
"clf = xgb.XGBClassifier(n_estimators=25, max_depth=5, learning_rate=1.0,\n",
" random_state=seed).fit(X_train_val, y_train_val)"
"clf = xgb.XGBClassifier(n_estimators=25, max_depth=5, learning_rate=1.0, random_state=seed).fit(X_train_val, y_train_val)"
]
},
{
@@ -150,7 +150,10 @@
"# add a legend\n",
"from matplotlib.lines import Line2D\n",
"\n",
"lines = [Line2D([0], [0], ls='--'), Line2D([0], [0], ls='-'),]\n",
"lines = [\n",
" Line2D([0], [0], ls='--'),\n",
" Line2D([0], [0], ls='-'),\n",
"]\n",
"from matplotlib.legend import Legend\n",
"\n",
"leg = Legend(ax, lines, labels=['part1 Keras', 'xgboost'], loc='lower right', frameon=False)\n",
@@ -222,7 +225,7 @@
"# print the help to see the API on the conifer_model\n",
"help(conifer_model)\n",
"# write the project (writing HLS project to disk)\n",
"conifer_model.write() \n",
"conifer_model.write()\n",
"# save the conifer model - we can load this again later\n",
"clf.save_model('model_5/xgboost_model.json')"
]
@@ -301,7 +304,7 @@
"metadata": {},
"outputs": [],
"source": [
"y_hls_proba = softmax(y_hls) # compute class probabilities from the raw predictions\n",
"y_hls_proba = softmax(y_hls) # compute class probabilities from the raw predictions\n",
"\n",
"print(f'Accuracy baseline: {accuracy_score(np.argmax(y_test_one_hot, axis=1), np.argmax(y_ref, axis=1)):.5f}')\n",
"print(f'Accuracy xgboost: {accuracy_score(np.argmax(y_test_one_hot, axis=1), np.argmax(y_xgb, axis=1)):.5f}')\n",
@@ -318,7 +321,11 @@
"# add a legend\n",
"from matplotlib.lines import Line2D\n",
"\n",
"lines = [Line2D([0], [0], ls='--'), Line2D([0], [0], ls=':'), Line2D([0], [0], ls='-'),]\n",
"lines = [\n",
" Line2D([0], [0], ls='--'),\n",
" Line2D([0], [0], ls=':'),\n",
" Line2D([0], [0], ls='-'),\n",
"]\n",
"from matplotlib.legend import Legend\n",
"\n",
"leg = Legend(ax, lines, labels=['part1 Keras', 'xgboost', 'conifer'], loc='lower right', frameon=False)\n",
@@ -390,11 +397,12 @@
"outputs": [],
"source": [
"pynq_model_cfg = conifer.backends.xilinxhls.auto_config()\n",
"pynq_model_cfg['OutputDir'] = 'model_5_pynq' # choose a new project directory\n",
"pynq_model_cfg['OutputDir'] = 'model_5_pynq' # choose a new project directory\n",
"pynq_model_cfg['ProjectName'] = 'conifer_jettag'\n",
"pynq_model_cfg['AcceleratorConfig'] = {'Board' : 'pynq-z2', # choose a pynq-z2 board\n",
" 'InterfaceType' : 'float' # floating point for the data I/O (this is default)\n",
" }\n",
"pynq_model_cfg['AcceleratorConfig'] = {\n",
" 'Board': 'pynq-z2', # choose a pynq-z2 board\n",
" 'InterfaceType': 'float', # floating point for the data I/O (this is default)\n",
"}\n",
"\n",
"# print the config\n",
"print('Modified Configuration\\n' + '-' * 50)\n",
8 changes: 6 additions & 2 deletions part6_cnns.ipynb
Original file line number Diff line number Diff line change
@@ -1546,11 +1546,15 @@
"import plotting\n",
"\n",
"# First, the baseline model\n",
"hls_config = hls4ml.utils.config_from_keras_model(model, granularity='name', backend='Vitis', default_precision='ap_fixed<16,6>' )\n",
"hls_config = hls4ml.utils.config_from_keras_model(\n",
" model, granularity='name', backend='Vitis', default_precision='ap_fixed<16,6>'\n",
")\n",
"\n",
"plotting.print_dict(hls_config)\n",
"\n",
"hls_model = hls4ml.converters.keras_to_hls(model, hls_config=hls_config, output_dir='pruned_cnn', backend='Vitis', part='xcu250-figd2104-2L-e', io_type='io_stream')\n",
"hls_model = hls4ml.converters.keras_to_hls(\n",
" model, hls_config=hls_config, output_dir='pruned_cnn', backend='Vitis', part='xcu250-figd2104-2L-e', io_type='io_stream'\n",
")\n",
"hls_model.compile()"
]
},

0 comments on commit 331465f

Please sign in to comment.