Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Error when Finetuning: WARNING:absl:Importing a function (__inference___call___15879) with ops with custom gradients. Will likely fail if a gradient is requested. #190

Open
aynesss opened this issue Feb 8, 2022 · 2 comments

Comments

@aynesss
Copy link

aynesss commented Feb 8, 2022

I work with TF version 2.4.1,
Here is how I finetune the saved checkpoint of ResNet :

###Model ##############################
def create_model():
    baseModel = tf.keras.models.load_model("gs://simclr-checkpoints-tf2/simclrv1/pretrain/1x/saved_model/")
    headModel = baseModel.output
    layer1 = tf.keras.layers.GlobalAveragePooling2D()(headModel)
    layer1 = tf.keras.layers.Flatten(name="flatten")(layer1)
    layer1 = tf.keras.layers.Dense(128, activation="relu", name="aa")(layer1)
    layer1 = tf.keras.layers.Dropout(0.5)(layer1)
    model_output = tf.keras.layers.Dense(3, activation="softmax", name="output")(layer1)  
    # compile the model
    model = tf.keras.Model(inputs=baseModel.input, outputs=model_output)
    for layer in model.layers:
        layer.trainable = True

    model.compile(optimizer=tf.keras.optimizers.SGD(learning_rate=0.001),
              loss=tf.keras.losses.CategoricalCrossentropy(), 
              metrics=[tf.keras.metrics.CategoricalAccuracy()])  
    return model

But I found this error:
WARNING:absl:Importing a function (__inference___call___15879) with ops with custom gradients. Will likely fail if a gradient is requested.

@AnasAr96
Copy link

AnasAr96 commented Jan 9, 2023

try to use this after the imports


import tensorflow as tf
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'  # Suppress TensorFlow logging (1)
tf.get_logger().setLevel('ERROR')  # Suppress TensorFlow logging (2)

@MMNavetty
Copy link

try to use this after the imports


import tensorflow as tf
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'  # Suppress TensorFlow logging (1)
tf.get_logger().setLevel('ERROR')  # Suppress TensorFlow logging (2)

Not working.. can't find a way to delete this annoying message

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants