Perhaps others may benefit from a concrete, reproducible answer. This post corresponds to this specific tfhub model.
tensorflow_hub version: 0.12.0
tensorflow version: 2.2.0
I set up the following path on my Linux server:
# Note, I manually created this entire path before ever downloading tfhub models
/opt/tfhub/tf2/bert_en_uncased_L-12_H-768_A-12_4/
(For various reasons, we have some needs for Tensorflow 1.x still, so I figured it might be a good idea to separate models based on if they are designed to work with tensorflow 1.x vs tensorflow 2.x, hence the tf2 in my path)
I then downloaded the model file, pushed it to my Linux server, placed it in the above location, and exectued:
# bash
tar xzf bert_en_uncased_L-12_H-768_A-12_4.tar.gz
That gave me the following files:
# python
import os
os.listdir("/opt/tfhub/tf2/bert_en_uncased_L-12_H-768_A-12_4/")
>>> ['keras_metadata.pb', 'saved_model.pb', 'assets', 'variables']
So then I can load the model like so:
# python
import tensorflow_hub as tfhub
import tensorflow as tf
bert_layer = tfhub.KerasLayer(tfhub.load("/opt/tfhub/tf2/bert_en_uncased_L-12_H-768_A-12_4"))