Skip to content

Commit

Permalink
Compatibility for data_based_init
Browse files Browse the repository at this point in the history
- also ensure that only trainable weights are updated
  • Loading branch information
krasserm committed Oct 5, 2018
1 parent 4682d5f commit d95423e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions keras/weightnorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,11 @@ def data_based_init(model, input):
# get all layer name, output, weight, bias tuples
layer_output_weight_bias = []
for l in model.layers:
if hasattr(l, 'W') and hasattr(l, 'b'):
trainable_weights = l.trainable_weights
if len(trainable_weights) == 2:
W,b = trainable_weights
assert(l.built)
layer_output_weight_bias.append( (l.name,l.get_output_at(0),l.W,l.b) ) # if more than one node, only use the first
layer_output_weight_bias.append((l.name,l.get_output_at(0),W,b)) # if more than one node, only use the first

# iterate over our list and do data dependent init
sess = K.get_session()
Expand Down

0 comments on commit d95423e

Please sign in to comment.