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

snapshot...

parent 4f329b22
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,7 @@ import pickle ...@@ -9,6 +9,7 @@ import pickle
import h5py import h5py
from icing.pirep_goes import split_data, normalize from icing.pirep_goes import split_data, normalize
from util.plot_cm import plot_confusion_matrix
LOG_DEVICE_PLACEMENT = False LOG_DEVICE_PLACEMENT = False
...@@ -240,9 +241,10 @@ class IcingIntensityNN: ...@@ -240,9 +241,10 @@ class IcingIntensityNN:
dataset = dataset.map(self.data_function, num_parallel_calls=8) dataset = dataset.map(self.data_function, num_parallel_calls=8)
self.test_dataset = dataset self.test_dataset = dataset
def setup_pipeline(self, filename): def setup_pipeline(self, filename, trn_idxs=None, tst_idxs=None):
self.filename = filename self.filename = filename
self.h5f = h5py.File(filename, 'r') self.h5f = h5py.File(filename, 'r')
if trn_idxs is None and tst_idxs is None:
time = self.h5f['time'] time = self.h5f['time']
num_obs = time.shape[0] num_obs = time.shape[0]
trn_idxs, tst_idxs = split_data(num_obs) trn_idxs, tst_idxs = split_data(num_obs)
...@@ -464,7 +466,7 @@ class IcingIntensityNN: ...@@ -464,7 +466,7 @@ class IcingIntensityNN:
t_loss = self.loss(labels, pred) t_loss = self.loss(labels, pred)
self.test_labels.append(labels) self.test_labels.append(labels)
self.test_preds.append(pred.result().numpy()) self.test_preds.append(pred.numpy())
self.test_loss(t_loss) self.test_loss(t_loss)
self.test_accuracy(labels, pred) self.test_accuracy(labels, pred)
...@@ -594,9 +596,13 @@ class IcingIntensityNN: ...@@ -594,9 +596,13 @@ class IcingIntensityNN:
for mini_batch_test in ds: for mini_batch_test in ds:
self.predict(mini_batch_test) self.predict(mini_batch_test)
print('loss, acc: ', self.test_loss.result(), self.test_accuracy.result()) 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() labels = np.concatenate(self.test_labels)
print(cm) preds = np.concatenate(self.test_preds)
preds = np.where(preds > 0.5, 1, 0)
self.test_labels = labels
self.test_preds = preds
def run(self, filename, filename_l1b=None): def run(self, filename, filename_l1b=None):
with tf.device('/device:GPU:'+str(self.gpu_device)): 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.
Please to comment