Skip to content

Commit 411f7c5

Browse files
committed
Removed usage of CPU threads from notebooks
1 parent b59f4c1 commit 411f7c5

File tree

4 files changed

+245
-56
lines changed

4 files changed

+245
-56
lines changed

pain_emnist_tf.ipynb

+1-13
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"**Implementation:** PAIN architecture presented in:\n",
1414
"**[IEEE publication](https://ieeexplore.ieee.org/abstract/document/8682767)**\n",
1515
"\n",
16-
"***NOTE:*** *Code is setup to reconstruct 7x7 compressed noisy images. Training parameters may need to be adjusted for 4x4, 14x14, and 28x28 cases.*\n",
16+
"***NOTE:*** *Code is setup to reconstruct 7x7 compressed noisy images. Batch size and learning rates may need to be adjusted for 4x4, 14x14, and 28x28 cases.*\n",
1717
"\n",
1818
"Python Version: 3.11.5 \n",
1919
"Jupyer Notebook Version: 6.5.4\n",
@@ -231,15 +231,6 @@
231231
"clean_test = np.array([matrix.reshape(out_dim**2,) for matrix in clean_test/255])"
232232
]
233233
},
234-
{
235-
"cell_type": "code",
236-
"execution_count": null,
237-
"metadata": {},
238-
"outputs": [],
239-
"source": [
240-
"[[clean_test.shape, clean_train.shape],[noisy_test.shape, noisy_train.shape]]"
241-
]
242-
},
243234
{
244235
"cell_type": "markdown",
245236
"metadata": {},
@@ -301,9 +292,6 @@
301292
},
302293
"outputs": [],
303294
"source": [
304-
"# Set threads using 6 CPU cores\n",
305-
"tf.config.threading.set_intra_op_parallelism_threads(6)\n",
306-
"\n",
307295
"# Create & Compile the PAIN model\n",
308296
"PAIN = build_PAIN(in_dim=cmp_dim, out_dim=out_dim)\n",
309297
"\n",

pain_tf.ipynb

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"**Implementation:** PAIN architecture presented in:\n",
1414
"**[IEEE publication](https://ieeexplore.ieee.org/abstract/document/8682767)**\n",
1515
"\n",
16-
"***NOTE:*** Code is setup to reconstruct 7x7 compressed noisy images. Training parameters may need to be adjusted for 4x4, 14x14, and 28x28 cases.\n",
16+
"***NOTE:*** *Code is setup to reconstruct 7x7 compressed noisy images. Batch size and learning rates may need to be adjusted for 4x4, 14x14, and 28x28 cases.*\n",
1717
"\n",
1818
"Python Version: 3.11.5 \n",
1919
"Jupyer Notebook Version: 6.5.4"
@@ -35,11 +35,14 @@
3535
"# Import necessary modules and libraries \n",
3636
"from __future__ import division, print_function, absolute_import\n",
3737
"import tensorflow as tf\n",
38+
"from tensorflow.keras.models import Model\n",
3839
"import numpy as np\n",
3940
"import matplotlib.pyplot as plt\n",
4041
"import h5py\n",
4142
"import os\n",
42-
"from skimage.util.shape import view_as_windows"
43+
"from skimage.util.shape import view_as_windows\n",
44+
"from sklearn.manifold import TSNE\n",
45+
"from sklearn.decomposition import PCA"
4346
]
4447
},
4548
{
@@ -202,7 +205,7 @@
202205
"dat_file = f'{directory}/mnist_{cmp_dim}x{cmp_dim}_train.h5'\n",
203206
" \n",
204207
"# Load MNIST\n",
205-
"(clean_train, _), (clean_test, _) = tf.keras.datasets.mnist.load_data()\n",
208+
"(clean_train, train_labels), (clean_test, test_labels) = tf.keras.datasets.mnist.load_data()\n",
206209
"\n",
207210
"# If the compressed/noisy data does not exist, create it\n",
208211
"if not os.path.exists(dat_file):\n",
@@ -288,9 +291,6 @@
288291
},
289292
"outputs": [],
290293
"source": [
291-
"# Set threads using 6 CPU cores\n",
292-
"tf.config.threading.set_intra_op_parallelism_threads(6)\n",
293-
"\n",
294294
"# Create & Compile the PAIN model\n",
295295
"PAIN = build_PAIN(in_dim=cmp_dim, out_dim=out_dim)\n",
296296
"\n",

pics_tf.ipynb

+1-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"**Implementation:** PICS architecture discussed in:\n",
1414
"**[IEEE publication](https://ieeexplore.ieee.org/abstract/document/8682767)**\n",
1515
"\n",
16-
"***NOTE:*** *Code is setup to reconstruct 7x7 compressed noisy images. Training parameters may need to be adjusted for 4x4, 14x14, and 28x28 cases.*\n",
16+
"***NOTE:*** *Code is setup to reconstruct 7x7 compressed noisy images. Batch size and learning rates may need to be adjusted for 4x4, 14x14, and 28x28 cases.*\n",
1717
"\n",
1818
"Python Version: 3.11.5 \n",
1919
"Jupyer Notebook Version: 6.5.4"
@@ -304,9 +304,6 @@
304304
},
305305
"outputs": [],
306306
"source": [
307-
"# Set threads using 6 CPU cores\n",
308-
"tf.config.threading.set_intra_op_parallelism_threads(6)\n",
309-
"\n",
310307
"# Create & Compile the PICS model\n",
311308
"PICS = build_PICS(in_dim=cmp_dim, out_dim=out_dim, flt_dim=2)\n",
312309
"\n",
@@ -370,9 +367,6 @@
370367
"metadata": {},
371368
"outputs": [],
372369
"source": [
373-
"# Print examples: training set\n",
374-
"################################\n",
375-
"\n",
376370
"# Create a 3 by 4 subplot handle\n",
377371
"fig, axes = plt.subplots(3, 4, figsize=(9, 8))\n",
378372
"axes = axes.flatten()\n",
@@ -439,9 +433,6 @@
439433
"metadata": {},
440434
"outputs": [],
441435
"source": [
442-
"# Print examples: test set\n",
443-
"################################\n",
444-
"\n",
445436
"# Create a 3 by 4 subplot handle\n",
446437
"fig, axes = plt.subplots(3, 4, figsize=(9, 8))\n",
447438
"axes = axes.flatten()\n",

sda_tf.ipynb

+237-27
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)