Skip to content

Commit

Permalink
Circumvent model (de)serialization bug in Keras
Browse files Browse the repository at this point in the history
Newer versions of Keras suffer from an inability to serialize a
Sequential model with an InputLayer properly (see
keras-team/keras#11683), which makes Keras
raise a ValueError when loading the model (see
keras-team/keras#10417). As a workaround,
remove the (auxiliary) InputLayer intil the issue has been fixed.
  • Loading branch information
krikru committed Feb 24, 2019
1 parent db05595 commit d0074d9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mnistdigitclassifierlib.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Kristofer Krus
# Copyright 2017, 2019 Kristofer Krus
#
# This file is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -97,8 +97,7 @@ def __init__(self,
elif classifier_type == ClassifierType.CNN:
# Create a convolutional neural network
self._model = Sequential()
self._model.add(InputLayer(input_shape=self._input_shape))
self._model.add(Conv2D(32, kernel_size=(3, 3), activation='relu'))
self._model.add(Conv2D(32, kernel_size=(3, 3), activation='relu', input_shape=self._input_shape))
if batch_normalization:
self._model.add(BatchNormalization())
self._model.add(Conv2D(64, (3, 3), activation='relu'))
Expand Down

0 comments on commit d0074d9

Please sign in to comment.