Guest User

Untitled

a guest
Sep 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #model creation
  2. base_model = applications.inception_v3.InceptionV3(include_top=False,
  3. weights='imagenet',
  4. pooling='avg',
  5. input_shape=(img_rows, img_cols, img_channel))
  6. #Adding custom Layers
  7. add_model = Sequential()
  8. add_model.add(Dense(128, activation='relu',input_shape=base_model.output_shape[1:],
  9. kernel_regularizer=regularizers.l2(0.001)))
  10. add_model.add(Dropout(0.60))
  11. add_model.add(Dense(2, activation='sigmoid'))
  12. # creating the final model
  13. model = Model(inputs=base_model.input, outputs=add_model(base_model.output))
  14.  
  15. model = load_model(os.path.join(ROOT_DIR,'model_1','model_cervigrams_all.h5'))
  16. #remove the last two layers
  17. #remove dense_2
  18. model.layers[-1].pop()
  19. #remove dropout_1
  20. model.layers[-1].pop()
  21. model.summary() # last alyer output shape is : (None, 128), so the removal worked
  22. #predict
  23. model.predict(np.reshape(image,[1,image.shape[0],image.shape[1],3])) #output only two values
Add Comment
Please, Sign In to add comment