simclr
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.
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.
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)
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