Skip to content

Instantly share code, notes, and snippets.

@SandroLuck
Created August 15, 2021 19:37
Show Gist options
  • Save SandroLuck/34f2af1d9cf391f34cb09126d0c2a129 to your computer and use it in GitHub Desktop.
Save SandroLuck/34f2af1d9cf391f34cb09126d0c2a129 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 7,
"id": "cf254b68",
"metadata": {},
"outputs": [],
"source": [
"# The user only specifies the input nodes and output heads.\n",
"import autokeras as ak\n",
"from keras.datasets import mnist\n",
"from autokeras import ImageClassifier"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "b595e403",
"metadata": {},
"outputs": [],
"source": [
"(x_train, y_train), (x_test, y_test) = mnist.load_data()\n",
"x_train = x_train.reshape(x_train.shape + (1,)) # (1,) denotes the channles which is 1 in this case\n",
"x_test = x_test.reshape(x_test.shape + (1,)) # (1,) denotes the channles which is 1 in this case"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9800df04",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Trial 1 Complete [00h 35m 25s]\n",
"val_loss: 0.040560998022556305\n",
"\n",
"Best val_loss So Far: 0.040560998022556305\n",
"Total elapsed time: 00h 35m 25s\n",
"\n",
"Search: Running Trial #2\n",
"\n",
"Hyperparameter |Value |Best Value So Far \n",
"image_block_1/b...|resnet |vanilla \n",
"image_block_1/n...|True |True \n",
"image_block_1/a...|True |False \n",
"image_block_1/i...|True |None \n",
"image_block_1/i...|True |None \n",
"image_block_1/i...|0 |None \n",
"image_block_1/i...|0 |None \n",
"image_block_1/i...|0.1 |None \n",
"image_block_1/i...|0 |None \n",
"image_block_1/r...|False |None \n",
"image_block_1/r...|resnet50 |None \n",
"image_block_1/r...|True |None \n",
"classification_...|global_avg |flatten \n",
"classification_...|0 |0.5 \n",
"optimizer |adam |adam \n",
"learning_rate |0.001 |0.001 \n",
"\n",
"Epoch 1/1000\n",
" 128/1500 [=>............................] - ETA: 6:03:54 - loss: 1.3791 - accuracy: 0.5776"
]
}
],
"source": [
"# Instantiate the ImageClassifier class\n",
"clf = ImageClassifier(num_classes=9)\n",
"# Fit the train set to the image classifier\n",
"clf.fit(x_train, y_train)\n",
"clf.final_fit(x_train, y_train, x_test, y_test, retrain=True)\n",
"# Summarize the results\n",
"y = clf.evaluate(x_test, y_test)\n",
"print(y * 100)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "505e920d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"environment": {
"name": "tf2-gpu.2-3.m76",
"type": "gcloud",
"uri": "gcr.io/deeplearning-platform-release/tf2-gpu.2-3:m76"
},
"kernelspec": {
"display_name": "Python [conda env:root] *",
"language": "python",
"name": "conda-root-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment