Skip to content

Commit

Permalink
Added zenodo data fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
jicampos committed Dec 13, 2024
1 parent e46f5b9 commit 4cc52e7
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 243 deletions.
182 changes: 25 additions & 157 deletions final/hls4ml.ipynb

Large diffs are not rendered by default.

110 changes: 24 additions & 86 deletions final/train.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,9 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"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",
"To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
"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",
"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",
"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",
"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",
"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",
"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"
]
}
],
"outputs": [],
"source": [
"import os \n",
"import pickle\n",
Expand Down Expand Up @@ -47,6 +32,17 @@
"## Download data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!wget https://zenodo.org/api/records/14427490/files-archive\n",
"!unzip files-archive -d data\n",
"# !rm files-archive # optional cleanup "
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -56,20 +52,20 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"train_data_dir = \"../data/malab_05282024/npz/\"\n",
"test_data_dir = \"../data/malab_05282024/npz/\"\n",
"train_data_dir = \"./data\"\n",
"test_data_dir = \"./data\"\n",
"start_location = 100\n",
"window_size = 400\n",
"end_window = start_location + window_size"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -94,7 +90,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -128,53 +124,9 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /data/jcampos/miniforge3/envs/ml4qick-env/lib/python3.10/site-packages/tensorflow/python/autograph/pyct/static_analysis/liveness.py:83: Analyzer.lamba_check (from tensorflow.python.autograph.pyct.static_analysis.liveness) is deprecated and will be removed after 2023-09-23.\n",
"Instructions for updating:\n",
"Lambda fuctions will be no more assumed to be used in the statement where they are used, or at least in the same block. https://github.com/tensorflow/tensorflow/issues/56089\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"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",
"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",
"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",
"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",
"To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Model: \"sequential\"\n",
"_________________________________________________________________\n",
" Layer (type) Output Shape Param # \n",
"=================================================================\n",
" fc1 (QDense) (None, 4) 3204 \n",
" \n",
" batchnorm1 (BatchNormalizat (None, 4) 16 \n",
" ion) \n",
" \n",
" fc2 (QDense) (None, 1) 5 \n",
" \n",
"=================================================================\n",
"Total params: 3,225\n",
"Trainable params: 3,217\n",
"Non-trainable params: 8\n",
"_________________________________________________________________\n",
"None\n"
]
}
],
"outputs": [],
"source": [
"model = keras.models.Sequential()\n",
"model.add(QDense(\n",
Expand Down Expand Up @@ -206,7 +158,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -228,7 +180,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -275,23 +227,9 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1563/1563 [==============================] - 1s 406us/step\n",
"1563/1563 [==============================] - 1s 389us/step\n",
"3125/3125 [==============================] - 1s 385us/step\n",
"\n",
"===================================\n",
" Accuracy 0.95999\n",
" Fidelity 0.9599899999999999\n"
]
}
],
"outputs": [],
"source": [
"# get ground and excited indices \n",
"e_indices = np.where(y_test == 1)[0]\n",
Expand Down

0 comments on commit 4cc52e7

Please sign in to comment.