I’m trying to use tensorflow and tensorflow_hub.
But during the tensorflow package import, I’m already getting the following error:
AttributeError: module ‘tensorflow._api.v2.compat.v2.internal’ has no attribute ‘register_load_context_function’. Did you mean: ‘register_call_context_function’?
I’m using the current version of python:
Python 3.12.2
And I’ve also reinstalled tensorflow packed some times, and followed other instructions I’ve found over discussions but not seems to helping.
Hey
Even I am facing the same problem. I am using the latest python version and I am trying to load one of my trained h5 model file which I have uploaded
from flask import Flask, request, render_template
import numpy as np
import tensorflow as tf
import tensorflow_hub as hub
app = Flask(__name__)
# Load the pre-trained BERT model
model = tf.keras.models.load_model(
("modelnew.h5"),
custom_objects={'KerasLayer':hub.KerasLayer}
)
can you make sure that TF and the tf-keras package both have the same version?
I’ve seen this error today and that was the main issue (specifically if you are using tf 2.16)