Skip to content

Commit 3e59b2a

Browse files
committed
add tested files with jax backend
1 parent e7a7be6 commit 3e59b2a

3 files changed

Lines changed: 9 additions & 13 deletions

File tree

examples/vision/ipynb/supervised-contrastive-learning.ipynb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
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
},
@@ -71,16 +71,15 @@
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
{
@@ -195,8 +194,7 @@
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
{
@@ -227,8 +225,7 @@
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
{
@@ -302,8 +299,7 @@
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
{
@@ -426,4 +422,4 @@
426422
},
427423
"nbformat": 4,
428424
"nbformat_minor": 0
429-
}
425+
}

examples/vision/md/supervised-contrastive-learning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ from keras import ops
4444

4545

4646
```python
47-
num_classes = 10
47+
num_classes = 50
4848
input_shape = (32, 32, 3)
4949

5050
# Load the train and test data splits

examples/vision/supervised-contrastive-learning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
## Prepare the data
3939
"""
4040

41-
num_classes = 10
41+
num_classes = 50
4242
input_shape = (32, 32, 3)
4343

4444
# Load the train and test data splits

0 commit comments

Comments
 (0)