Closed piri-p closed 1 year ago
[Update] Dear @singhniraj08 thank you again for the swift response! I followed the instruction, switching trainable
to False
and putting the following snippet before re-compiling the model, but it complains exactly the same error.
hub_layer = hub.KerasLayer(
model_source,
trainable=False # per https://github.com/tensorflow/hub/issues/862
)
...
...
...
model.trainable = True
# Fine-tune starting from BERT encoder layer (Layer 2)
fine_tune_at = 2
# Freeze all the layers before the `fine_tune_at` layer
for layer in model.layers[:fine_tune_at]:
layer.trainable = False
for layer in model.layers[fine_tune_at:]:
layer.trainable = True
@piriyacoco,
I tried the same code with below TF versions and I cannot reproduce the error.
I am loading the model with trainable = True
parameter. Please check the gist here. Thank you!
tensorflow==2.9.0 tensorflow-text==2.9.0 tensorflow-hub==0.12.0 Python==3.7.3
Dear @singhniraj08
Thank you for checking! I just made a gist here for error reproducibility. The error occurs when fitting the model.
tensorflow==2.9.0 tensorflow-text==2.9.0 tensorflow-hub==0.12.0 Python==3.7.13
@piriyacoco
I have tried same code to reproduce without error and I'm able to reproduce it on Google Colab and I have tried below versions, it's working fine without error so kindly please try below versions for required libraries and I hope it will also work for you, even for your reference I've added Gist file here
I have added learning resource for you also here for NLP use case with Tensorflow, I hope it will help you in your learning or NLP use case
Here is versions details to install libraries :
tensorflow==2.8.0
tensorflow-text==2.8.2
tensorflow-hub==0.10.0
Python==3.7.15
If issue still persists please let us know ? Thank you!
Hi @gaikwadrahul8
Thank you for your response! So I think you are using the TF version 2.8 right? Do you think it is the issue with TF version 2.9 I used, or what exactly is the problem. I am just trying to understand here :)
@piriyacoco
I noticed there is version compatibility issue between TF Hub and TF version with NLP Pre-trained models on TF Hub so as work around I would suggest you to go with Tensorflow==2.8.0 for your use case and everything will work fine for you
Could you please confirm if this issue is resolved for you ?Please feel free to close the issue if it is resolved ?
Thank you!
Hi, @piriyacoco
Update: While using BERT preprocessing from TFHub, Tensorflow and tensorflow_text versions should be same so please make sure that installed both versions are same. It happens because you're using latest version for tensorflow_text but you're using other versions for python and tensorflow but there is internal dependancy with versions for Tensorflow and tensorflow_text which should be same.
Please refer similar issue over stackoverflow here if you have any further questions or you need any further assistance please re-open this issue ?
Closing this issue due to lack of recent activity for couple of weeks. Please feel free to reopen the issue with more details if the problem still persists after trying above workaround. Thank you!
What happened?
I was trying to use fine-tune BERT from TFHub for text classification task. The run with
trainable=True
crashes withInvalidArgumentError: When determinism is enabled, random ops must have a seed specified.
[[{{node dropout/dropout/random_uniform/RandomUniform}}]] [Op:__inference_train_function_XXXX]
I already try setting the seeds and also "not" enable determinism mode, but no avails. This fails for other BERT models on TFHub as well.
It does not crash with
trainable=False
.Relevant code
Relevant log output
tensorflow_hub Version
0.12.0 (latest stable release)
TensorFlow Version
other (please specify)
Other libraries
tensorflow==2.9.0 tensorflow-text==2.9.0
Python 3.9 under Conda 4.12.0 all Tensorflow packages installed via pip
Python Version
3.x
OS
Linux