Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the efficientnet-lite provided by tfhub for the second training on tf2.1

The version I use is tensorflow-gpu version 2.1.0, installed from pip.

import tensorflow as tf
import tensorflow_hub as hub

tf.keras.backend.set_learning_phase(True)

module_url = "https://tfhub.dev/tensorflow/efficientnet/lite0/classification/2"

module2 = tf.keras.Sequential([
    hub.KerasLayer(module_url, trainable=False, input_shape=(224,224,3))])

output1 = module2(tf.ones(shape=(1,224,224,3)))
print(module2.summary())

When I set trainable = True, the operation will give an error. So, can't I retrain it on tf2.1 version?

like image 365
chenbin tang Avatar asked Nov 06 '22 08:11

chenbin tang


1 Answers

The EfficientNet-Lite models on TFHub are based on TensorFlow 1, and thus are subject to many restrictions on TF2 including fine-tuning as you've discovered. The EfficientNet models were updated to TF2 but we're still waiting for their lite counterparts.

https://www.tensorflow.org/hub/model_compatibility

https://github.com/tensorflow/hub/issues/751

UPDATE: Beginning October 5, 2021, the EfficientNet-Lite models on TFHub are available for TensorFlow 2.

like image 130
willbattel Avatar answered Nov 15 '22 13:11

willbattel