Skip to content

Commit 1028dba

Browse files
committed
Updating params
1 parent 5734e32 commit 1028dba

File tree

1 file changed

+8
-39
lines changed

1 file changed

+8
-39
lines changed

notebooks/scan_window_location_and_size_NN.ipynb

+8-39
Original file line numberDiff line numberDiff line change
@@ -436,19 +436,19 @@
436436
"\n",
437437
"# 64 total runs \n",
438438
"for idx, window_size in enumerate(all_window_sizes):\n",
439+
" X_train_val = np.load(x_train_path) # need to load data again to avoid memory issues \n",
440+
" X_test = np.load(x_test_path)\n",
439441
" for jdx, start_location in enumerate(all_window_start_locations):\n",
440442
" #########################\n",
441443
" # 0. prep data \n",
442444
" #########################\n",
443445
" # check if window size is too big for start location\n",
444446
" if start_location+window_size > 770:\n",
445-
" all_fidelity[idx, jdx] = -1\n",
447+
" all_fidelity[idx, jdx] = np.nan\n",
446448
" print(f'Skipping start location={start_location}, window size={window_size}')\n",
447449
" continue\n",
448-
" X_train_val = np.load(x_train_path) # need to load data again to avoid memory issues \n",
449-
" X_test = np.load(x_test_path)\n",
450-
" X_train_val = X_train_val[:,start_location*2:(start_location+window_size)*2]\n",
451-
" X_test = X_test[:,start_location*2:(start_location+window_size)*2]\n",
450+
" X_train_val_window = X_train_val[:,start_location*2:(start_location+window_size)*2]\n",
451+
" X_test_window = X_test[:,start_location*2:(start_location+window_size)*2]\n",
452452
"\n",
453453
" #########################\n",
454454
" # 1. init callbacks\n",
@@ -487,7 +487,7 @@
487487
" # 3. train \n",
488488
" #########################\n",
489489
" history = model.fit(\n",
490-
" X_train_val, \n",
490+
" X_train_val_window, \n",
491491
" y_train_val, \n",
492492
" batch_size=batch_size,\n",
493493
" epochs=epochs, \n",
@@ -507,42 +507,11 @@
507507
" #########################\n",
508508
" # 4. compute fidelity \n",
509509
" #########################\n",
510-
" y_pred = model.predict(X_test)\n",
510+
" y_pred = model.predict(X_test_window)\n",
511511
" test_acc = accuracy_score(np.argmax(y_test, axis=1), np.argmax(y_pred, axis=1))\n",
512512
" all_accuracy[idx, jdx] = test_acc\n",
513513
" all_fidelity[idx, jdx] = test_acc*2-1\n",
514514
" \n",
515-
" # # get ground and excited indices \n",
516-
" # e_indices = np.where(np.argmax(y_test, axis=1) == 1)[0]\n",
517-
" # g_indices = np.where(np.argmax(y_test, axis=1) == 0)[0]\n",
518-
"\n",
519-
" # # separate ground and excited samples \n",
520-
" # Xe_test = X_test_window[e_indices]\n",
521-
" # ye_test = np.argmax(y_test, axis=1)[e_indices]\n",
522-
"\n",
523-
" # Xg_test = X_test_window[g_indices]\n",
524-
" # yg_test = np.argmax(y_test, axis=1)[g_indices]\n",
525-
"\n",
526-
" # # compute total correct for excited state \n",
527-
" # ye_pred = model.predict(Xe_test)\n",
528-
" # e_accuracy = accuracy_score(ye_test, np.argmax(ye_pred, axis=1))\n",
529-
"\n",
530-
" # total_correct = (ye_test==np.argmax(ye_pred, axis=1)).astype(np.int8).sum()\n",
531-
" # total_incorrect = (ye_test!=np.argmax(ye_pred, axis=1)).astype(np.int8).sum()\n",
532-
"\n",
533-
" # # compute total correct for ground state \n",
534-
" # yg_pred = model.predict(Xg_test)\n",
535-
" # g_accuracy = accuracy_score(yg_test, np.argmax(yg_pred, axis=1))\n",
536-
"\n",
537-
" # total_correct = (yg_test==np.argmax(yg_pred, axis=1)).astype(np.int8).sum()\n",
538-
" # total_incorrect = (yg_test!=np.argmax(yg_pred, axis=1)).astype(np.int8).sum()\n",
539-
"\n",
540-
" # all_e_accuracy.append(e_accuracy)\n",
541-
" # all_g_accuracy.append(g_accuracy)\n",
542-
"\n",
543-
" # compute fidelity \n",
544-
" # fidelity = 0.5*(e_accuracy + g_accuracy)\n",
545-
" # all_fidelity[jdx, idx] = fidelity\n",
546515
" print('\\n===================================')\n",
547516
" print(f'Start location = {start_location}, Window size = {window_size}')\n",
548517
" print(' Accuracy', test_acc)\n",
@@ -555,7 +524,7 @@
555524
"metadata": {},
556525
"outputs": [],
557526
"source": [
558-
"outfile = '_2-layer_scan_window_size_and_location_window_size_600_770.npz'\n",
527+
"outfile = '_2-layer_scan_window_size_and_location_window_size_0_770.npz'\n",
559528
"note = f'Training data on 0528, readout fidelity with 2-layer NN, scanned window size and location, window size 770'\n",
560529
"\n",
561530
"np.savez(\n",

0 commit comments

Comments
 (0)