Flexible Transfer Learning with TensorFlow and Keras Applications

Joshua Owoyemi
1 min readApr 27, 2019
Tensorflow + Keras

I have been searching for a simple yet flexible way to do transfer learning with TensorFlow recently. However, most examples I see are either too cryptic and involved or too rigid to be repurposed.

So, I stumbled on this tutorial on the TensorFlow website, which helped only if I wanted to use the pretrained models as feature extractor or just finetune them. I wanted more. I wanted a way to be able to use the pretrained layers and weights. Then I realized the tutorial was based on the keras applications which is a collection of pretrained models and weights provided by the Keras team and ported into TensorFlow.

After some tinkering using the TensorFlow and Keras API, we can easily reuse layers and pretrained weights of the models from the Keras applications. The code snippet is provided below or in this Github Gist. You might need to see the TensorFlow tutorial first if you are not familiar with transfer learning.

--

--