simclr icon indicating copy to clipboard operation
simclr copied to clipboard

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

Open aynesss opened this issue 3 years ago • 2 comments

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.

aynesss avatar Feb 08 '22 10:02 aynesss

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)

AnasAr96 avatar Jan 09 '23 23:01 AnasAr96

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

MMNavetty avatar Apr 19 '24 09:04 MMNavetty