Hi I'm trying to train a MobileNetV3Small model on a custom image classification pipeline on my M1 MacBook Pro using tensorflow-metal. While the code runs without error, the model doesn't seem to train at all - it predicts the same class for any input after training. I have already experimented with similar training on the same dataset with torchvision mobilenetv2 (on a GPU cluster) where I got over 60% accuracy (on 1098 image classes) after 2 epochs. I've included my code below, where even evaluating on the training set after training leads to poor performance. Any ideas what I could be doing wrong?
import tensorflow as tf
EPOCHS = 1
BATCH_SIZE = 128
LEARNING_RATE = 0.003
SEED=1220
if __name__ == '__main__':
# Load train and validation data
train_ds = tf.keras.preprocessing.image_dataset_from_directory(
'/Volumes/detext/drawings/',
color_mode="grayscale",
seed=SEED,
batch_size=BATCH_SIZE,
labels='inferred',
label_mode='int',
image_size=(200,300))
# Get the class names
class_names = train_ds.class_names
num_classes = len(class_names)
# Create model
model = tf.keras.applications.MobileNetV3Small(
input_shape=(200,300,1), alpha=1.0, minimalistic=False,
include_top=True, weights=None, input_tensor=None, classes=num_classes,
pooling=None, classifier_activation="softmax",
include_preprocessing=True)
# Compile model
model.compile(
optimizer=tf.keras.optimizers.Adam(learning_rate=LEARNING_RATE),
loss=tf.keras.losses.SparseCategoricalCrossentropy(),
metrics=[tf.keras.metrics.SparseCategoricalAccuracy()])
# Training
model.fit(x=train_ds, epochs=EPOCHS)
# Testing
hist = model.evaluate(x=train_ds)
print(hist)
model.save('./saved_model3/')
Post
Replies
Boosts
Views
Activity
Every time I try to upload the Mac Catalyst build of my App to App Store Connect, I get the following error:
Asset validation failed
This bundle is invalid. The value for key CFBundleVersion [3] in the Info.plist file must contain a higher version than that of the previously uploaded version [8]. Please find more information about CFBundleVersion at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion (ID: 60d6b17f-ea3e-4e82-a6e6-21c18e6fb9ef)
I have tried updating the version and build numbers in Xcode - still getting the same error. The Info.plist also looks fine - it just contains $(CURRENT_PROJECT_VERSION) next to Bundle version.
The kicker is that I'm having no issues with uploading iOS builds - only Mac Catalyst builds. Any help would be appreciated - I've been stuck on this problem for months!
I'm running Xcode 14 on macOS 12.5.1