Advertisement
warrior98

Untitled

Sep 23rd, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. import keras
  2. from keras import backend as K
  3. from keras.layers.core import Dense, Activation
  4. from keras.optimizers import Adam
  5. from keras.metrics import mean_squared_error
  6. from keras.preprocessing.image import ImageDataGenerator
  7. from keras.preprocessing import image
  8. from keras.models import Model
  9. from keras.applications import imagenet_utils
  10. from keras.layers import Dense, GlobalAveragePooling2D
  11. from keras.applications import MobileNetV2
  12. from keras.applications.mobilenet import preprocess_input
  13. import numpy as np
  14. from IPython.display import Image
  15. from keras.optimizers import Adam
  16.  
  17. # imports the mobilenet model and discards the last 1000 neuron layer.
  18. base_model = MobileNetV2(weights='imagenet', include_top=False)
  19.  
  20. x = base_model.output
  21. x = GlobalAveragePooling2D()(x)
  22. # we add dense layers so that the model can learn more complex functions and classify for better results.
  23. x = Dense(512, activation='relu')(x)  # dense layer 3
  24. preds = Dense(1, activation='relu')(x)  # final layer with softmax activation
  25.  
  26. base_model.compile(optimizer='Adam', loss='mean_squared_error')
  27. base_model.summary()
  28.  
  29. # https://towardsdatascience.com/transfer-learning-using-mobilenet-and-keras-c75daf7ff299
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement