Skip to content

Commit

Permalink
updates for keras preprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
zchholmes committed Dec 9, 2018
1 parent 9ff75fe commit 3a3cadb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions docs/preprocess/Keras/src_py/keras_model.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import tensorflow as tf
import numpy as np
from keras.models import Sequential, Model
from keras.models import Sequential, Model, load_model
from keras.layers import Dense, Input, InputLayer, Conv2D, MaxPooling2D, Reshape, Flatten
from keras.models import load_model

mnist = tf.keras.datasets.mnist

(x_train, y_train),(x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

def create_sequential_model():
single_output_model = Sequential([
Expand All @@ -24,6 +21,7 @@ def create_sequential_model():
])
return single_output_model


def create_model():
input_tensor = Input(shape=(28, 28))
reshape_layer = Reshape((28, 28, 1), input_shape=(28, 28,))(input_tensor)
Expand All @@ -45,6 +43,7 @@ def create_model():
)
return classic_model


def train_model():
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
Expand All @@ -64,6 +63,7 @@ def train_model():
def save_model(model, name_path):
model.save(name_path)


def load_from_model(name_path):
model = load_model(name_path)
# Load model from json+weights
Expand All @@ -78,13 +78,15 @@ def load_from_model(name_path):
# model.load_weights(weight_path)
return model


def generate_encapsulate_model_with_output_layer_names(model, output_layer_names):
enc_model = Model(
inputs=model.input,
outputs=list(map(lambda oln: model.get_layer(oln).output, output_layer_names))
)
return enc_model

s
def generate_encapsulate_model(model):
enc_model = Model(
inputs=model.input,
Expand Down
Binary file modified docs/preprocess/img/intro_preprocess_m.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3a3cadb

Please sign in to comment.