Skip to content

Commit

Permalink
AE w/ and w/o classifier
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoValente3 committed Nov 30, 2021
1 parent d9fdee0 commit 1894d71
Show file tree
Hide file tree
Showing 95 changed files with 474 additions and 25,287 deletions.
644 changes: 463 additions & 181 deletions AE.ipynb

Large diffs are not rendered by default.

Binary file added AE_model/KERAS_check_model_w_classifier.h5
Binary file not shown.
Binary file added AE_model/KERAS_check_model_wo_classifier.h5
Binary file not shown.
23 changes: 11 additions & 12 deletions MNIST_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# | MNIST data class |
# +------------------+


class MNISTData:
"""MNIST data class. You can adjust the data_fraction to use when creating
the data, according to your system capabilities."""
Expand All @@ -20,29 +21,23 @@ def __init__(self, data_fraction=1., zoom_factor = None):
(self.x_train, self.y_train), (self.x_test, self.y_test) = data.load_data()

self.get_subset_of_data(data_fraction)
if zoom_factor is not None:
self.interpolate(zoom_factor)

self.convert_label_to_categorical()

self.normalize_mnist_images()

if zoom_factor is not None:
self.interpolate(zoom_factor)

self.reshape_to_color_channel()


self.flatten_pictures()

def interpolate(self, zoom_factor):
#self.x_train = scipy.ndimage.zoom(self.x_train,
# (1, zoom_factor, zoom_factor, 1))
#shape_train = self.x_train.shape[1]*self.x_train.shape[2]
#self.x_train.reshape([196,])


self.x_train = scipy.ndimage.zoom(self.x_train,
(1, zoom_factor, zoom_factor))
self.x_test = scipy.ndimage.zoom(self.x_test,
(1, zoom_factor, zoom_factor))

#shape_test = self.x_test.shape[1]*self.x_test.shape[2]
#self.x_test.reshape([196,])

def convert_label_to_categorical(self):
self.y_train = to_categorical(self.y_train)
Expand All @@ -64,3 +59,7 @@ def get_subset_of_data(self, data_fraction):
index = int(len(self.x_test) * data_fraction)
self.x_test = self.x_test[:index]
self.y_test = self.y_test[:index]

def flatten_pictures(self):
self.x_train = self.x_train.reshape(self.x_train.shape[0], -1)
self.x_test = self.x_test.reshape(self.x_test.shape[0], -1)
Binary file modified __pycache__/MNIST_dataset.cpython-38.pyc
Binary file not shown.
Binary file modified images/AE/Accuracy of Autoencoder without classifier.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/AE/reconstructed images.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed model_1/KERAS_check_best_model.h5
Binary file not shown.
Binary file removed model_1/hls4ml_prj.tar.gz
Binary file not shown.
17 changes: 0 additions & 17 deletions model_1/hls4ml_prj/build_lib.sh

This file was deleted.

134 changes: 0 additions & 134 deletions model_1/hls4ml_prj/build_prj.tcl

This file was deleted.

Loading

0 comments on commit 1894d71

Please sign in to comment.