Skip to content

Commit e46f5b9

Browse files
committed
Update fidelity
1 parent 927382b commit e46f5b9

File tree

2 files changed

+34
-61
lines changed

2 files changed

+34
-61
lines changed

final/hls4ml.ipynb

+2
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@
491491
"\n",
492492
"# compute fidelity \n",
493493
"keras_fidelity = 0.5*(e_accuracy + g_accuracy)\n",
494+
"keras_fidelity = keras_fidelity*2-1\n",
494495
"keras_fidelity = 1/2 + (0.5*keras_fidelity)\n",
495496
"\n",
496497
"\n",
@@ -512,6 +513,7 @@
512513
"\n",
513514
"# compute fidelity \n",
514515
"hls_fidelity = 0.5*(e_accuracy + g_accuracy)\n",
516+
"hls_fidelity = hls_fidelity*2-1\n",
515517
"hls_fidelity = 1/2 + (0.5*hls_fidelity)\n",
516518
"\n",
517519
"\n",

final/train.ipynb

+32-61
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 2,
5+
"execution_count": 1,
66
"metadata": {},
77
"outputs": [
88
{
99
"name": "stderr",
1010
"output_type": "stream",
1111
"text": [
12-
"2024-12-02 10:50:03.729385: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 AVX_VNNI FMA\n",
12+
"2024-12-02 12:11:43.237267: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 AVX_VNNI FMA\n",
1313
"To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
14-
"2024-12-02 10:50:03.793060: I tensorflow/core/util/port.cc:104] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.\n",
15-
"2024-12-02 10:50:03.794942: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory\n",
16-
"2024-12-02 10:50:03.794954: I tensorflow/compiler/xla/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.\n",
17-
"2024-12-02 10:50:06.943195: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory\n",
18-
"2024-12-02 10:50:06.943319: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory\n",
19-
"2024-12-02 10:50:06.943333: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.\n"
14+
"2024-12-02 12:11:43.289566: I tensorflow/core/util/port.cc:104] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.\n",
15+
"2024-12-02 12:11:43.291412: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory\n",
16+
"2024-12-02 12:11:43.291421: I tensorflow/compiler/xla/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.\n",
17+
"2024-12-02 12:11:43.592090: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory\n",
18+
"2024-12-02 12:11:43.592117: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory\n",
19+
"2024-12-02 12:11:43.592120: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.\n"
2020
]
2121
}
2222
],
@@ -56,7 +56,7 @@
5656
},
5757
{
5858
"cell_type": "code",
59-
"execution_count": 3,
59+
"execution_count": 2,
6060
"metadata": {},
6161
"outputs": [],
6262
"source": [
@@ -69,7 +69,7 @@
6969
},
7070
{
7171
"cell_type": "code",
72-
"execution_count": 4,
72+
"execution_count": 3,
7373
"metadata": {},
7474
"outputs": [],
7575
"source": [
@@ -94,7 +94,7 @@
9494
},
9595
{
9696
"cell_type": "code",
97-
"execution_count": 5,
97+
"execution_count": 4,
9898
"metadata": {},
9999
"outputs": [],
100100
"source": [
@@ -128,7 +128,7 @@
128128
},
129129
{
130130
"cell_type": "code",
131-
"execution_count": 6,
131+
"execution_count": 5,
132132
"metadata": {},
133133
"outputs": [
134134
{
@@ -144,10 +144,10 @@
144144
"name": "stderr",
145145
"output_type": "stream",
146146
"text": [
147-
"2024-12-02 10:51:09.801613: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory\n",
148-
"2024-12-02 10:51:09.801630: W tensorflow/compiler/xla/stream_executor/cuda/cuda_driver.cc:265] failed call to cuInit: UNKNOWN ERROR (303)\n",
149-
"2024-12-02 10:51:09.801640: I tensorflow/compiler/xla/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (correlator7.fnal.gov): /proc/driver/nvidia/version does not exist\n",
150-
"2024-12-02 10:51:09.801767: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 AVX_VNNI FMA\n",
147+
"2024-12-02 12:12:42.530268: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory\n",
148+
"2024-12-02 12:12:42.530285: W tensorflow/compiler/xla/stream_executor/cuda/cuda_driver.cc:265] failed call to cuInit: UNKNOWN ERROR (303)\n",
149+
"2024-12-02 12:12:42.530294: I tensorflow/compiler/xla/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (correlator7.fnal.gov): /proc/driver/nvidia/version does not exist\n",
150+
"2024-12-02 12:12:42.530419: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 AVX_VNNI FMA\n",
151151
"To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n"
152152
]
153153
},
@@ -206,7 +206,7 @@
206206
},
207207
{
208208
"cell_type": "code",
209-
"execution_count": 7,
209+
"execution_count": 6,
210210
"metadata": {},
211211
"outputs": [],
212212
"source": [
@@ -230,46 +230,9 @@
230230
"cell_type": "code",
231231
"execution_count": 8,
232232
"metadata": {},
233-
"outputs": [
234-
{
235-
"name": "stdout",
236-
"output_type": "stream",
237-
"text": [
238-
"Epoch 1/50\n",
239-
"3340/3340 [==============================] - 9s 2ms/step - loss: 0.1959 - accuracy: 0.9558 - val_loss: 0.1810 - val_accuracy: 0.9581\n",
240-
"Epoch 2/50\n",
241-
"3340/3340 [==============================] - 10s 3ms/step - loss: 0.1802 - accuracy: 0.9592 - val_loss: 0.1770 - val_accuracy: 0.9583\n",
242-
"Epoch 3/50\n",
243-
"3340/3340 [==============================] - 3s 800us/step - loss: 0.1787 - accuracy: 0.9595 - val_loss: 0.1783 - val_accuracy: 0.9584\n",
244-
"Epoch 4/50\n",
245-
"3340/3340 [==============================] - 8s 2ms/step - loss: 0.1782 - accuracy: 0.9598 - val_loss: 0.1776 - val_accuracy: 0.9585\n",
246-
"Epoch 5/50\n",
247-
"3340/3340 [==============================] - 9s 3ms/step - loss: 0.1792 - accuracy: 0.9593 - val_loss: 0.1770 - val_accuracy: 0.9583\n",
248-
"Epoch 6/50\n",
249-
"3340/3340 [==============================] - 6s 2ms/step - loss: 0.1791 - accuracy: 0.9593 - val_loss: 0.1796 - val_accuracy: 0.9582\n",
250-
"Epoch 7/50\n",
251-
"3340/3340 [==============================] - 6s 2ms/step - loss: 0.1784 - accuracy: 0.9598 - val_loss: 0.1783 - val_accuracy: 0.9588\n",
252-
"Epoch 8/50\n",
253-
"3340/3340 [==============================] - 2s 671us/step - loss: 0.1779 - accuracy: 0.9597 - val_loss: 0.1783 - val_accuracy: 0.9584\n",
254-
"Epoch 9/50\n",
255-
"3340/3340 [==============================] - 6s 2ms/step - loss: 0.1779 - accuracy: 0.9601 - val_loss: 0.1783 - val_accuracy: 0.9586\n",
256-
"Epoch 10/50\n",
257-
"3340/3340 [==============================] - 11s 3ms/step - loss: 0.1778 - accuracy: 0.9599 - val_loss: 0.1777 - val_accuracy: 0.9587\n",
258-
"Epoch 11/50\n",
259-
"3340/3340 [==============================] - 8s 2ms/step - loss: 0.1778 - accuracy: 0.9599 - val_loss: 0.1775 - val_accuracy: 0.9584\n",
260-
"Epoch 12/50\n",
261-
"3340/3340 [==============================] - 11s 3ms/step - loss: 0.1779 - accuracy: 0.9599 - val_loss: 0.1781 - val_accuracy: 0.9583\n",
262-
"Epoch 13/50\n",
263-
"3340/3340 [==============================] - 11s 3ms/step - loss: 0.1779 - accuracy: 0.9599 - val_loss: 0.1779 - val_accuracy: 0.9584\n",
264-
"Epoch 14/50\n",
265-
"3340/3340 [==============================] - 6s 2ms/step - loss: 0.1779 - accuracy: 0.9599 - val_loss: 0.1775 - val_accuracy: 0.9586\n",
266-
"Epoch 15/50\n",
267-
"3340/3340 [==============================] - 8s 2ms/step - loss: 0.1778 - accuracy: 0.9600 - val_loss: 0.1772 - val_accuracy: 0.9585\n"
268-
]
269-
}
270-
],
233+
"outputs": [],
271234
"source": [
272-
"train = True\n",
235+
"train = False\n",
273236
"\n",
274237
"if train: \n",
275238
" opt = Adam(learning_rate=init_learning_rate)\n",
@@ -312,20 +275,20 @@
312275
},
313276
{
314277
"cell_type": "code",
315-
"execution_count": 28,
278+
"execution_count": 10,
316279
"metadata": {},
317280
"outputs": [
318281
{
319282
"name": "stdout",
320283
"output_type": "stream",
321284
"text": [
322-
"1563/1563 [==============================] - 1s 484us/step\n",
323-
"1563/1563 [==============================] - 1s 359us/step\n",
324-
"3125/3125 [==============================] - 1s 391us/step\n",
285+
"1563/1563 [==============================] - 1s 406us/step\n",
286+
"1563/1563 [==============================] - 1s 389us/step\n",
287+
"3125/3125 [==============================] - 1s 385us/step\n",
325288
"\n",
326289
"===================================\n",
327290
" Accuracy 0.95999\n",
328-
" Fidelity 0.979995\n"
291+
" Fidelity 0.9599899999999999\n"
329292
]
330293
}
331294
],
@@ -359,6 +322,7 @@
359322
"\n",
360323
"# compute fidelity \n",
361324
"test_fidelity = 0.5*(e_accuracy + g_accuracy)\n",
325+
"test_fidelity = test_fidelity*2-1\n",
362326
"test_fidelity = 1/2 + (0.5*test_fidelity)\n",
363327
"\n",
364328
"y_pred = model.predict(X_test)\n",
@@ -368,6 +332,13 @@
368332
"print(' Accuracy', test_acc)\n",
369333
"print(' Fidelity', test_fidelity)"
370334
]
335+
},
336+
{
337+
"cell_type": "code",
338+
"execution_count": null,
339+
"metadata": {},
340+
"outputs": [],
341+
"source": []
371342
}
372343
],
373344
"metadata": {

0 commit comments

Comments
 (0)