Keras models

Advanced Deep Learning with Keras

Zach Deane-Mayer

Data Scientist

Keras models

from tensorflow.keras.layers import Input, Dense
input_tensor = Input(shape=(1,))
output_tensor = Dense(1)(input_tensor)

Advanced Deep Learning with Keras

Keras models

from tensorflow.keras.models import Model
model = Model(input_tensor, output_tensor)

Advanced Deep Learning with Keras

Compile a model

model.compile(optimizer='adam', loss='mae')

Advanced Deep Learning with Keras

Summarize the model

model.summary()

Model: "model"
_________________________________________________________________
 Layer (type)                Output Shape              Param #   
=================================================================
 input_1 (InputLayer)        [(None, 1)]               0         

 dense (Dense)               (None, 1)                 2         

=================================================================
Total params: 2
Trainable params: 2
Non-trainable params: 0
_________________________________________________________________
Advanced Deep Learning with Keras

Plot model using keras

input_tensor = Input(shape=(1,))
output_layer = Dense(1, name='Predicted-Score-Diff')
output_tensor = output_layer(input_tensor)
model = Model(input_tensor, output_tensor)
plot_model(model, to_file ='model.png')

from matplotlib import pyplot as plt
img = plt.imread('model.png')
plt.imshow(img)
plt.show()

Advanced Deep Learning with Keras

Let's practice!

Advanced Deep Learning with Keras

Preparing Video For Download...