Skip to content

Commit

Permalink
ValueError: You called set_weights(weights) on layer conv1_1 with a…
Browse files Browse the repository at this point in the history
… weight list of length 0, but the layer was expecting 2 weights.
  • Loading branch information
cl0ver012 committed May 14, 2018
1 parent c6f3eb1 commit c699e00
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def migrate_model(img_rows, img_cols, channel=4):

for i in range(2, 31):
old_layer = old_layers[i]
new_layer = new_layers[i]
new_layer = new_layers[i + 1]
new_layer.set_weights(old_layer.get_weights())

# flatten = old_model.get_layer('flatten')
Expand Down
3 changes: 2 additions & 1 deletion model.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def create_model(img_rows, img_cols, channel=4):

if __name__ == '__main__':
model = create_model(320, 320, 4)
input_layer = model.get_layer('input')
# input_layer = model.get_layer('input')
print(model.summary())

K.clear_session()
9 changes: 9 additions & 0 deletions vgg16.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

import keras.backend as K
from keras.layers import Conv2D, ZeroPadding2D, MaxPooling2D
from keras.layers import Dense, Dropout, Flatten
from keras.models import Sequential
Expand Down Expand Up @@ -57,3 +58,11 @@ def vgg16_model(img_rows, img_cols, channel=3):
model.load_weights(weights_path)

return model


if __name__ == '__main__':
model = vgg16_model(224, 224, 3)
# input_layer = model.get_layer('input')
print(model.summary())

K.clear_session()

0 comments on commit c699e00

Please sign in to comment.