Classifying Galaxies: Classifying Galaxies Using Convolutional Neural Networks

https://www.codecademy.com/paths/build-deep-learning-models-with-tensorflow/tracks/dlsp-classification-track/modules/dlsp-image-classification/projects/classifying-galaxies-deep-learning

Hi guys. I am getting some errors when I use model.fit for this exercise and I can’t resolve the problem. Does anyone know what is wrong? I have attached the codes below and the errors printed out in the command window:

CODES:
import tensorflow as tf

from tensorflow.keras.preprocessing.image import ImageDataGenerator

from sklearn.model_selection import train_test_split

from utils import load_galaxy_data

import app

input_data, labels = load_galaxy_data()

print(input_data.shape)

features_train, features_test, labels_train, labels_test = train_test_split(input_data, labels, test_size=0.2, random_state=222, stratify=labels)

data_generator = ImageDataGenerator(rescale=1.0/128)

BATCH_SIZE = 5

training_iterator = data_generator.flow(features_train, labels_train, batch_size=BATCH_SIZE)

validation_iterator = data_generator.flow(features_test, labels_test, batch_size=BATCH_SIZE)

model = tf.keras.Sequential()

model.add(tf.keras.layers.Input(shape=(128, 128, 1)))

model.add(tf.keras.layers.Conv2D(8, 3, strides=2, activation=‘relu’))

model.add(tf.keras.layers.MaxPooling2D(pool_size=(2,2), strides=2))

model.add(tf.keras.layers.Conv2D(8, 3, strides=2, activation=‘relu’))

model.add(tf.keras.layers.MaxPooling2D(pool_size=(2,2), strides=2))

model.add(tf.keras.layers.Flatten())

model.add(tf.keras.layers.Dense(16, activation=‘relu’))

model.add(tf.keras.layers.Dense(4, activation=‘softmax’))

model.compile(

loss=tf.keras.losses.CategoricalCrossentropy(),

optimizer=tf.keras.optimizers.Adam(learning_rate=0.001),

metrics=[tf.keras.metrics.CategoricalAccuracy(), tf.keras.metrics.AUC()]

)

model.summary()

model.fit(training_iterator, steps_per_epoch=len(features_train)/BATCH_SIZE, epochs=8, validation_data=validation_iterator, validation_steps=len(labels_train)/BATCH_SIZE)

ERRORS from command window:
Traceback (most recent call last):
File “train.py”, line 39, in
model.fit(training_iterator, steps_per_epoch=len(features_train)/BATCH_SIZE, epochs=8, validation_data=validation_iterator, validation_steps=len(labels_train)/BATCH_SIZE)
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py”, line 66, in _method_wrapper
return method(self, *args, **kwargs)
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py”, line 848, in fit
tmp_logs = train_function(iterator)
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py”, line 580, in call
result = self._call(*args, **kwds)
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py”, line 644, in _call
return self._stateless_fn(*args, **kwds)
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py”, line 2420, in call
return graph_function._filtered_call(args, kwargs) # pylint: disable=protected-access
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py”, line 1665, in _filtered_call
self.captured_inputs)
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py”, line 1746, in _call_flat
ctx, args, cancellation_manager=cancellation_manager))
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py”, line 598, in call
ctx=ctx)
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/execute.py”, line 60, in quick_execute
inputs, attrs, num_outputs)
tensorflow.python.framework.errors_impl.UnimplementedError: Fused conv implementation does not support grouped convolutions for now.
[[node sequential/conv2d/Relu (defined at train.py:39) ]] [Op:__inference_train_function_1111]

Function call stack:
train_function