1010 " \n " ,
1111 " **Author:** [Khalid Salama](https://www.linkedin.com/in/khalid-salama-24403144/)<br>\n " ,
1212 " **Date created:** 2020/11/30<br>\n " ,
13- " **Last modified:** 2026/07/17 <br>\n " ,
13+ " **Last modified:** 2026/08/04 <br>\n " ,
1414 " **Description:** Using supervised contrastive learning for image classification."
1515 ]
1616 },
7171 },
7272 "outputs" : [],
7373 "source" : [
74- " num_classes = 10 \n " ,
74+ " num_classes = 50 \n " ,
7575 " input_shape = (32, 32, 3)\n " ,
7676 " \n " ,
7777 " # Load the train and test data splits\n " ,
7878 " (x_train, y_train), (x_test, y_test) = keras.datasets.cifar10.load_data()\n " ,
7979 " \n " ,
8080 " # Display shapes of train and test datasets\n " ,
8181 " print(f\" x_train shape: {x_train.shape} - y_train shape: {y_train.shape}\" )\n " ,
82- " print(f\" x_test shape: {x_test.shape} - y_test shape: {y_test.shape}\" )\n " ,
83- " "
82+ " print(f\" x_test shape: {x_test.shape} - y_test shape: {y_test.shape}\" )\n "
8483 ]
8584 },
8685 {
195194 " loss=keras.losses.SparseCategoricalCrossentropy(),\n " ,
196195 " metrics=[keras.metrics.SparseCategoricalAccuracy()],\n " ,
197196 " )\n " ,
198- " return model\n " ,
199- " "
197+ " return model\n "
200198 ]
201199 },
202200 {
227225 " history = classifier.fit(x=x_train, y=y_train, batch_size=batch_size, epochs=num_epochs)\n " ,
228226 " \n " ,
229227 " accuracy = classifier.evaluate(x_test, y_test)[1]\n " ,
230- " print(f\" Test accuracy: {round(accuracy * 100, 2)}%\" )\n " ,
231- " "
228+ " print(f\" Test accuracy: {round(accuracy * 100, 2)}%\" )\n "
232229 ]
233230 },
234231 {
302299 " model = keras.Model(\n " ,
303300 " inputs=inputs, outputs=outputs, name=\" cifar-encoder_with_projection-head\"\n " ,
304301 " )\n " ,
305- " return model\n " ,
306- " "
302+ " return model\n "
307303 ]
308304 },
309305 {
426422 },
427423 "nbformat" : 4 ,
428424 "nbformat_minor" : 0
429- }
425+ }
0 commit comments