From d1b67d1dfd48fa125425d9f205ff53117e32fe76 Mon Sep 17 00:00:00 2001 From: andrewschreiber Date: Thu, 29 Aug 2019 20:44:49 -0700 Subject: [PATCH 1/3] fix: use float64 instead of float --- model/layers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/model/layers.py b/model/layers.py index 2a69dc5..441888b 100644 --- a/model/layers.py +++ b/model/layers.py @@ -147,7 +147,7 @@ def backward(self, dy): def parameters(self): return - + def load(self, weights, bias): return @@ -231,7 +231,7 @@ def __init__(self): self.out = None def forward(self, inputs): - exp = np.exp(inputs, dtype=np.float) + exp = np.exp(inputs, dtype=np.float64) self.out = exp/np.sum(exp) return self.out @@ -240,6 +240,6 @@ def backward(self, dy): def parameters(self): return - + def load(self, weights, bias): return From 35c062fb27cc4391583edf6d1e0b21e897985ddd Mon Sep 17 00:00:00 2001 From: andrewschreiber Date: Sat, 10 Aug 2019 16:03:34 -0700 Subject: [PATCH 2/3] feat: add dtypes to loss calculations --- main.py | 2 +- model/loss.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 43cbb97..cd42676 100644 --- a/main.py +++ b/main.py @@ -28,7 +28,7 @@ net.load("10epoch_weights.pkl") -#net.train(training_data[:100], training_labels[:100], 32, 3, 'weights.pkl') +net.train(training_data, training_labels, 32, 3, 'weights.pkl') net.test(testing_data[:500], testing_labels[:500]) diff --git a/model/loss.py b/model/loss.py index 7248a3a..1996c99 100644 --- a/model/loss.py +++ b/model/loss.py @@ -3,6 +3,6 @@ def cross_entropy(inputs, labels): out_num = labels.shape[0] - probability = np.sum(labels.reshape(1, out_num) * inputs) - loss = -np.log(probability) + probability = np.sum(labels.reshape(1, out_num) * inputs, dtype=np.float64) + loss = -np.log(probability, dtype=np.float64) return loss From 40cd1e003613e6d331379476524608f9614a7c1c Mon Sep 17 00:00:00 2001 From: andrewschreiber Date: Sat, 10 Aug 2019 16:06:05 -0700 Subject: [PATCH 3/3] feat: match train epochs with pretrained weights --- main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index cd42676..e7cc6e1 100644 --- a/main.py +++ b/main.py @@ -28,8 +28,8 @@ net.load("10epoch_weights.pkl") -net.train(training_data, training_labels, 32, 3, 'weights.pkl') +net.train(training_data, training_labels, 32, 10, 'weights.pkl') -net.test(testing_data[:500], testing_labels[:500]) +net.test(testing_data[:50], testing_labels[:50]) # save_vanilla_gradient(net, training_data[:25], training_labels[:25], 5)