From 7dca17ba1375a0b00d7835f598b4e20b7aab37a2 Mon Sep 17 00:00:00 2001 From: hma02 Date: Thu, 20 Jul 2017 16:58:29 -0400 Subject: [PATCH] fixing the missing hkl import, preprocessing (#22) in models: alexnet, googlenet, resnet50, vgg16 --- theanompi/models/alex_net.py | 22 ++++++++++++++++-- theanompi/models/googlenet.py | 22 ++++++++++++++++-- .../models/lasagne_model_zoo/resnet50.py | 23 +++++++++++++++++-- theanompi/models/lasagne_model_zoo/vgg16.py | 22 ++++++++++++++++-- 4 files changed, 81 insertions(+), 8 deletions(-) diff --git a/theanompi/models/alex_net.py b/theanompi/models/alex_net.py index 06425fc..32df437 100644 --- a/theanompi/models/alex_net.py +++ b/theanompi/models/alex_net.py @@ -419,7 +419,16 @@ def train_iter(self, count,recorder): else: - arr = hkl.load(img[self.current_t]) #- img_mean + img_mean = self.data.rawdata[-1] + import hickle as hkl + arr = hkl.load(img[self.current_t]) - img_mean + + from theanompi.models.data.utils import crop_and_mirror + + arr = crop_and_mirror(arr, mode, + rand_crop, + batch_crop_mirror, + input_width) self.shared_x.set_value(arr) @@ -510,7 +519,16 @@ def val_iter(self, count,recorder): else: - arr = hkl.load(img[self.current_v]) #- img_mean + img_mean = self.data.rawdata[-1] + import hickle as hkl + arr = hkl.load(img[self.current_v]) - img_mean + + from theanompi.models.data.utils import crop_and_mirror + + arr = crop_and_mirror(arr, mode, + rand_crop, + batch_crop_mirror, + input_width) # arr = np.rollaxis(arr,0,4) diff --git a/theanompi/models/googlenet.py b/theanompi/models/googlenet.py index 0e0060b..0311fe6 100644 --- a/theanompi/models/googlenet.py +++ b/theanompi/models/googlenet.py @@ -766,7 +766,16 @@ def train_iter(self, count, recorder): else: - arr = hkl.load(img[self.current_t]) #- img_mean + img_mean = self.data.rawdata[-1] + import hickle as hkl + arr = hkl.load(img[self.current_t]) - img_mean + + from theanompi.models.data.utils import crop_and_mirror + + arr = crop_and_mirror(arr, mode, + rand_crop, + batch_crop_mirror, + input_width) self.shared_x.set_value(arr) @@ -857,7 +866,16 @@ def val_iter(self, count,recorder): else: - arr = hkl.load(img[self.current_v]) #- img_mean + img_mean = self.data.rawdata[-1] + import hickle as hkl + arr = hkl.load(img[self.current_v]) - img_mean + + from theanompi.models.data.utils import crop_and_mirror + + arr = crop_and_mirror(arr, mode, + rand_crop, + batch_crop_mirror, + input_width) # arr = np.rollaxis(arr,0,4) diff --git a/theanompi/models/lasagne_model_zoo/resnet50.py b/theanompi/models/lasagne_model_zoo/resnet50.py index dab103d..fec7f79 100644 --- a/theanompi/models/lasagne_model_zoo/resnet50.py +++ b/theanompi/models/lasagne_model_zoo/resnet50.py @@ -489,7 +489,16 @@ def train_iter(self, count,recorder): else: - arr = hkl.load(img[self.current_t]) #- img_mean + img_mean = self.data.rawdata[-1] + import hickle as hkl + arr = hkl.load(img[self.current_t]) - img_mean + + from theanompi.models.data.utils import crop_and_mirror + + arr = crop_and_mirror(arr, mode, + rand_crop, + batch_crop_mirror, + input_width) self.shared_x.set_value(arr) @@ -580,7 +589,17 @@ def val_iter(self, count,recorder): else: - arr = hkl.load(img[self.current_v]) #- img_mean + img_mean = self.data.rawdata[-1] + + import hickle as hkl + arr = hkl.load(img[self.current_v]) - img_mean + + from theanompi.models.data.utils import crop_and_mirror + + arr = crop_and_mirror(arr, mode, + rand_crop, + batch_crop_mirror, + input_width) # arr = np.rollaxis(arr,0,4) diff --git a/theanompi/models/lasagne_model_zoo/vgg16.py b/theanompi/models/lasagne_model_zoo/vgg16.py index b42867d..7f65e70 100644 --- a/theanompi/models/lasagne_model_zoo/vgg16.py +++ b/theanompi/models/lasagne_model_zoo/vgg16.py @@ -393,7 +393,16 @@ def train_iter(self, count,recorder): else: - arr = hkl.load(img[self.current_t]) #- img_mean + img_mean = self.data.rawdata[-1] + import hickle as hkl + arr = hkl.load(img[self.current_t]) - img_mean + + from theanompi.models.data.utils import crop_and_mirror + + arr = crop_and_mirror(arr, mode, + rand_crop, + batch_crop_mirror, + input_width) self.shared_x.set_value(arr) @@ -484,7 +493,16 @@ def val_iter(self, count,recorder): else: - arr = hkl.load(img[self.current_v]) #- img_mean + img_mean = self.data.rawdata[-1] + import hickle as hkl + arr = hkl.load(img[self.current_v]) - img_mean + + from theanompi.models.data.utils import crop_and_mirror + + arr = crop_and_mirror(arr, mode, + rand_crop, + batch_crop_mirror, + input_width) # arr = np.rollaxis(arr,0,4)