tensorflow / hub

A library for transfer learning by reusing parts of TensorFlow models.
https://tensorflow.org/hub
Apache License 2.0
3.49k stars 1.67k forks source link

fine tuning for multi lingual mobilebert #806

Closed tano1750 closed 3 years ago

tano1750 commented 3 years ago

I did finetuning for mobilebert_multi_cased_L-24_H-128_B-512_A-4_F-4_OPT with model maker. But it finish abnormally.

from tflite_model_maker import text_classifier from tflite_model_maker.config import ExportFormat from tflite_model_maker.text_classifier import MobileBertClassifierSpec from tflite_model_maker.text_classifier import DataLoader

spec = MobileBertClassifierSpec(uri='https://tfhub.dev/tensorflow/mobilebert_multi_cased_L-24_H-128_B-512_A-4_F-4_OPT/1', model_dir=None, seq_len=128, dropout_rate=0.1, initializer_range = 0.02, learning_rate = 3e-05, distribution_strategy = 'off', num_gpus = -1, tpu = '', trainable = True, do_lower_case = True, is_tf2 = False, name = 'MobileBert', tflite_input_name=None, default_batch_size=48 ) data_dir = os.path.dirname(".\") replace_label(os.path.join(os.path.join(data_dir, 'train.tsv')), 'train.csv') replace_label(os.path.join(os.path.join(data_dir, 'dev.tsv')), 'dev.csv')

train_data = DataLoader.from_csv( filename='train.csv', text_column='sentence', label_column='label', model_spec=spec, is_training=True) test_data = DataLoader.from_csv( filename='dev.csv', text_column='sentence', label_column='label', model_spec=spec, is_training=False)

model = text_classifier.create(train_data, model_spec=spec, epochs=3) ...

Environment -Windows10 -Anaconda2020.07 -Python3.8 -tensorflow2.6.0 -tflite-model-maker0.3.2

Error message is displayed like below. Traceback (most recent call last): File "main.py", line 78, in model = text_classifier.create(train_data, model_spec=spec, epochs=3) ......... File "C:xxxxx\lib\site-packages\tensorflow_hub\keras_layer.py", line 309, in _getcallable raise ValueError("Unknown signature %s in %s (available signatures: %s)." ValueError: Unknown signature tokens in https://tfhub.dev/tensorflow/mobilebert multi_cased_L-24_H-128_B-512_A-4_F-4_OPT/1 (available signatures: _SignatureMap({'serving_default': <ConcreteFunction signature_wrapper(*, input_word_ids, input_type_ids, input_mask) at 0x601DDAAD90>})).

I try to do finetuning for uncased_L-24_H-128_B-512_A-4_F-4_OPT(https://tfhub.dev/google/mobilebert/uncased_L-24_H-128_B-512_A-4_F-4_OPT/1) with same source. It finish normally. I can get tflite model. What should I do anything when I use mulit lingual model, ?

UsharaniPagadala commented 3 years ago

@tano1750 Could you please refer these link1 and link2, hope it helps.Thanks

UsharaniPagadala commented 3 years ago

@tano1750

Closing this issue due to inactivity.Please feel free to reopen if this still exist.Thanks