Feature Extraction
TensorFlow Hub provides the option of downloading a model without the final layer. In this case, you will be using a TensorFlow module as a feature extractor; you can design your custom final layers on top of it. In TensorFlow Hub, a module used for feature extraction is known as a feature vector:
import tensorflow_hub as hub MODULE_HANDLE = 'https://tfhub.dev/google/efficientnet/b0'\ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â '/feature-vector/1' module = hub.load(MODULE_HANDLE)
Note
To find all the available feature vectors on TensorFlow Hub, you can use its search engine: https://tfhub.dev/s?module-type=image-feature-vector&tf-version=tf2.
Once loaded, you can add your own final layer to the feature vector with the Sequential API:
model = tf.keras.Sequential([ Â Â Â Â hub.KerasLayer(MODULE_HANDLE, input_shape=(224, 224, 3)), Â Â Â Â tf.keras...