Skip to content
Snippets Groups Projects
Commit 4f329b22 authored by tomrink's avatar tomrink
Browse files

snapshot...

parent be74e20a
No related branches found
No related tags found
No related merge requests found
......@@ -145,6 +145,10 @@ class IcingIntensityNN:
self.test_auc = None
self.test_recall = None
self.test_precision = None
self.test_confusion_matrix = None
self.test_labels = []
self.test_preds = []
self.learningRateSchedule = None
self.num_data_samples = None
......@@ -370,7 +374,7 @@ class IcingIntensityNN:
fc = tf.keras.layers.BatchNormalization()(fc)
print(fc.shape)
# activation = tf.nn.softmax
# activation = tf.nn.softmax # For multi-class
activation = tf.nn.sigmoid # For binary
logits = tf.keras.layers.Dense(NumLabels, activation=activation)(fc)
......@@ -459,6 +463,9 @@ class IcingIntensityNN:
pred = self.model(inputs, training=False)
t_loss = self.loss(labels, pred)
self.test_labels.append(labels)
self.test_preds.append(pred.result().numpy())
self.test_loss(t_loss)
self.test_accuracy(labels, pred)
self.test_auc(labels, pred)
......@@ -517,6 +524,9 @@ class IcingIntensityNN:
with self.writer_valid.as_default():
tf.summary.scalar('loss_val', self.test_loss.result(), step=step)
tf.summary.scalar('acc_val', self.test_accuracy.result(), step=step)
tf.summary.scalar('auc_val', self.test_auc.result(), step=step)
tf.summary.scalar('recall_val', self.test_recall.result(), step=step)
tf.summary.scalar('prec_val', self.test_precision.result(), step=step)
tf.summary.scalar('num_train_steps', step, step=step)
tf.summary.scalar('num_epochs', epoch, step=step)
......@@ -584,6 +594,9 @@ class IcingIntensityNN:
for mini_batch_test in ds:
self.predict(mini_batch_test)
print('loss, acc: ', self.test_loss.result(), self.test_accuracy.result())
cm = tf.math.confusion_matrix(np.concatenate(self.test_labels), np.concatenate(self.test_preds), num_classes=2)
cm = cm.result().numpy()
print(cm)
def run(self, filename, filename_l1b=None):
with tf.device('/device:GPU:'+str(self.gpu_device)):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment