|
17 | 17 | ] |
18 | 18 | }, |
19 | 19 | { |
| 20 | + "attachments": {}, |
20 | 21 | "cell_type": "markdown", |
21 | 22 | "metadata": {}, |
22 | 23 | "source": [ |
23 | | - "#### Turn Off Messages:" |
| 24 | + "#### Turn Off Messages & Set GPU Memory Growth:" |
24 | 25 | ] |
25 | 26 | }, |
26 | 27 | { |
|
31 | 32 | "source": [ |
32 | 33 | "import os\n", |
33 | 34 | "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'\n", |
34 | | - "\n", |
35 | | - "# Fix: UnknownError: Failed to get convolution algorithm. \n", |
36 | | - "# This is probably because cuDNN failed to initialize, \n", |
37 | | - "# so try looking to see if a warning log message was printed above\n", |
38 | 35 | "os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true'" |
39 | 36 | ] |
40 | 37 | }, |
|
100 | 97 | "import numpy as np\n", |
101 | 98 | "import pandas as pd\n", |
102 | 99 | "from random import randint\n", |
103 | | - "from tensorflow.keras import layers, regularizers\n", |
104 | 100 | "from keras.models import Sequential, load_model\n", |
105 | 101 | "from keras.datasets import cifar10\n", |
106 | 102 | "from keras.callbacks import ModelCheckpoint\n", |
107 | 103 | "from keras.utils import to_categorical\n", |
108 | | - "from keras.applications.vgg16 import preprocess_input\n", |
109 | 104 | "from keras.layers import Dense, Conv2D, Flatten, Dropout, Activation, MaxPooling2D, BatchNormalization\n", |
110 | 105 | "from keras.preprocessing.image import ImageDataGenerator\n", |
111 | | - "from sklearn.metrics import accuracy_score, confusion_matrix, recall_score" |
| 106 | + "from sklearn.metrics import accuracy_score, confusion_matrix" |
112 | 107 | ] |
113 | 108 | }, |
114 | 109 | { |
|
124 | 119 | "metadata": {}, |
125 | 120 | "outputs": [], |
126 | 121 | "source": [ |
127 | | - "# plot training accuracy and loss\n", |
128 | | - "def plotCurve(trainingAccuracy, trainingLoss):\n", |
129 | | - " epochs = np.arange(trainingLoss.shape[0])\n", |
130 | | - " #print(epochs)\n", |
131 | | - " plt.figure(figsize = [12, 6])\n", |
132 | | - " plt.subplot(1, 2, 1)\n", |
133 | | - " plt.plot(epochs, trainingAccuracy)\n", |
134 | | - " #plt.axis([-1, 2, -1, 2])\n", |
135 | | - " plt.xlabel('Epoch')\n", |
136 | | - " plt.ylabel('Accuracy')\n", |
137 | | - " plt.title('Training Accuracy')\n", |
138 | | - "\n", |
139 | | - " plt.subplot(1, 2, 2)\n", |
140 | | - " plt.plot(epochs, trainingLoss)\n", |
141 | | - " plt.xlabel('Epoch')\n", |
142 | | - " plt.ylabel('Binary CrossEntropy Loss')\n", |
143 | | - " plt.title('Training Loss')\n", |
144 | | - " plt.show()\n", |
145 | | - "\n", |
146 | 122 | "# Plot Features of CIFAR-10 data\n", |
147 | 123 | "def feat_plot(features, labels, classes, title):\n", |
148 | 124 | " for class_i in classes:\n", |
|
480 | 456 | "metadata": {}, |
481 | 457 | "outputs": [], |
482 | 458 | "source": [ |
483 | | - "save_path6 = '../assets/Lecture7/model3_ckpt.h5'\n", |
| 459 | + "save_path6 = '../assets/Lecture7/model6_ckpt.h5'\n", |
484 | 460 | "callbacks_save6 = ModelCheckpoint(save_path6, monitor='val_loss', verbose=0, save_best_only=True, save_freq='epoch')\n", |
485 | 461 | "\n", |
486 | 462 | "opt6 = tf.keras.optimizers.Adam(learning_rate=0.01)\n", |
|
0 commit comments