Skip to content

Commit

Permalink
Change encoder-decoder option parameter for an offset parameter
Browse files Browse the repository at this point in the history
This way, the offset can be adjusted directly in the call, and saves
time adjusting the offset in the code.

Also, it allows the tfglib code to work with less changes and commits
  • Loading branch information
albertaparicio committed Jan 24, 2017
1 parent 8c392aa commit e112a04
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions tfglib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def display_time(seconds, granularity=2):
return ', '.join([x for x in result[:granularity] if x is not None])


def s2s_load_weights(model, filepath, mode):
def s2s_load_weights(model, filepath, offset=0):
import h5py
from keras import backend as K
w_file = h5py.File(filepath, mode='r')
Expand Down Expand Up @@ -147,17 +147,6 @@ def s2s_load_weights(model, filepath, mode):
filtered_layers.append(layer)
indexes.append(index)

if mode is 'encoder':
offset = 0

elif mode is 'decoder':
# offset = 6
offset = 5

else:
raise Exception("Unrecognized mode. Please choose 'encoder' or" +
" 'decoder' as a mode")

indexes = [index + offset for index in indexes]
flattened_layers = filtered_layers

Expand Down

0 comments on commit e112a04

Please sign in to comment.