Closed LukeWood closed 1 year ago
@innat I am not getting any error, am i doing something wrong.
import tensorflow as tf
from tensorflow import keras
import keras_cv
import os
tpu = None
try:
tpu = tf.distribute.cluster_resolver.TPUClusterResolver()
tf.config.experimental_connect_to_cluster(tpu)
tf.tpu.experimental.initialize_tpu_system(tpu)
strategy = tf.distribute.experimental.TPUStrategy(tpu)
except:
strategy = tf.distribute.get_strategy()
def create_model():
with strategy.scope():
backbone = keras_cv.models.EfficientNetV2Backbone.from_preset("efficientnetv2_b0_imagenet")
model = keras_cv.models.ImageClassifier(backbone=backbone,
num_classes=10,
activation="softmax")
# Compile model
model.compile(loss = 'sparse_categorical_crossentropy',
optimizer= tf.keras.optimizers.Adam(),
metrics = ['accuracy'], jit_compile=True)
return model
model = create_model()
@IMvision12, I believe @innat was providing a reference to the XLA compatibility checker used by keras-nlp and not implying that keras-cv already has one.
All models should support XLA now that we're on Keras Core
an example of this is EfficientNetV2. if you pass
jit_compile=True
to the model, you'll get:Not very helpful for a user that doesn't have a deep understanding of TF/Keras/XLA. We can address this in backbones directly, and in
ImageClassifier
/OD models/etc by checking some sort ofsupports_xla
attribute backbones can expose.