diff --git a/part2/part2_compression.ipynb b/part2/part2_compression.ipynb index 8a1776c9603db79852deddef3a00d688fa12f400..47bd6e0a897c391c0eda004b13eb58889374aa18 100644 --- a/part2/part2_compression.ipynb +++ b/part2/part2_compression.ipynb @@ -127,7 +127,7 @@ }, { "cell_type": "markdown", - "id": "808a79e1", + "id": "3410ddb1", "metadata": {}, "source": [ "## Translating to a QKeras QAT model\n", @@ -347,6 +347,8 @@ "id": "a275844b", "metadata": {}, "source": [ + "### <span style=\"color:green\">This takes a minute to plot, read on while you wait (2 minutes)</span>\n", + "\n", "In this case, the values seem to be mostly <50, with a few outliers so lets assume 6 integer bits ($2^6=64$) is sufficient (the rest will get clipped). The number of fractional bits will define our precision, and will affect the network performance. Let's assume 10 is sufficient (the smallest increment we can represent is $2^{-10}=0.0009765625$).\n", "\n", "We can evaluate these choices by comparing the accuracy of the network to that in the previous part. \n", @@ -670,7 +672,9 @@ "## Validate the firmware model accuracy\n", "\n", "#et's also run predict on the C++ implementation of our model and make sure it's the ~same as for the QKeras model.\n", - "This is very slow for the C++ implementation of our model, but we need a lot of statistics to probe the low rate region. Keep reading while you wait :)!\n" + "This is very slow for the C++ implementation of our model, but we need a lot of statistics to probe the low rate region.\n", + "\n", + "### <span style=\"color:green\">Execute the next cell, then grab a quick coffee while its running (<5 minutes)</span>\n" ] }, { @@ -682,6 +686,7 @@ "source": [ "y_hls = hls_model.predict(np.ascontiguousarray(qX_test))\n", "\n", + "# Let's print and compare some of the predictions:\n", "print(f\"Truth labels:\\n {y_test[17:27]}\\n\")\n", "print(f\"Qkeras prediction:\\n {qy_pred[17:27]}\\n\")\n", "print(f\"HLS prediction:\\n {y_hls[17:27]}\\n\")" @@ -715,6 +720,20 @@ "plt" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "eb1429d2", + "metadata": {}, + "outputs": [], + "source": [ + "# Save the predictions for later\n", + "np.save('y_pred_hls', y_hls)\n", + "np.save('y_pred_qkeras', qy_pred)\n", + "np.save('y_pred_float', y_pred)\n", + "np.save('y_test', y_test)" + ] + }, { "cell_type": "markdown", "id": "00985383", @@ -726,7 +745,9 @@ "\n", "Now let's build it! Lets run C-synthesis (C++ to register-transfer level) and Vivado logic synthesis (gate level representation). We will not do co-simulation (send test vectors, do an exhaustive functional test of the implemented logic), but this can be a good idea if you are using CNNs and the $io_stream$ io. \n", "\n", - "Let's run!" + "Let's run!\n", + "\n", + "### <span style=\"color:green\">Execute the next cell, then go grab a snack (~15 minute)</span>" ] }, { @@ -791,7 +812,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5d954d26", + "id": "5d51cef5", "metadata": {}, "outputs": [], "source": []