Skip to content

Commit

Permalink
added weight loading
Browse files Browse the repository at this point in the history
  • Loading branch information
jhartford committed Jul 28, 2017
1 parent efa3870 commit 2f42ee2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions deepiv/models.py
Expand Up @@ -11,6 +11,12 @@
from keras.models import Model
from keras import backend as K
from keras.layers import Lambda, InputLayer
from keras.engine import topology
try:
import h5py
except ImportError:
h5py = None


import keras.utils

Expand Down Expand Up @@ -404,3 +410,14 @@ def __getitem__(self, idx):
if idx == (len(self) - 1):
self.shuffle()
return batch_features, batch_y

def load_weights(filepath, model):
if h5py is None:
raise ImportError('`load_weights` requires h5py.')

with h5py.File(filepath, mode='r') as f:
# set weights
topology.load_weights_from_hdf5_group(f['model_weights'], model.layers)

return model

0 comments on commit 2f42ee2

Please sign in to comment.