-
-
Save kiransair/8d6a6e4d8616f0cb9a99adb082ba801e to your computer and use it in GitHub Desktop.
TF_Forum_21171.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"provenance": [], | |
"authorship_tag": "ABX9TyOmBNeHtNIJsoWBkW0nryuB", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/kiransair/8d6a6e4d8616f0cb9a99adb082ba801e/tf_forum_21171.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "dGt5ydc2pOoB", | |
"outputId": "ca615fc9-f257-48b0-ce98-24c45caa3ec8" | |
}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Collecting autokeras\n", | |
" Downloading autokeras-1.1.0-py3-none-any.whl (148 kB)\n", | |
"\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/148.6 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m148.6/148.6 kB\u001b[0m \u001b[31m4.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | |
"\u001b[?25hRequirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from autokeras) (23.2)\n", | |
"Requirement already satisfied: tensorflow>=2.8.0 in /usr/local/lib/python3.10/dist-packages (from autokeras) (2.14.0)\n", | |
"Collecting keras-tuner>=1.1.0 (from autokeras)\n", | |
" Downloading keras_tuner-1.4.6-py3-none-any.whl (128 kB)\n", | |
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m128.9/128.9 kB\u001b[0m \u001b[31m7.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | |
"\u001b[?25hCollecting keras-nlp>=0.4.0 (from autokeras)\n", | |
" Downloading keras_nlp-0.6.3-py3-none-any.whl (584 kB)\n", | |
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m584.5/584.5 kB\u001b[0m \u001b[31m12.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | |
"\u001b[?25hRequirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from autokeras) (1.5.3)\n", | |
"Collecting keras-core (from keras-nlp>=0.4.0->autokeras)\n", | |
" Downloading keras_core-0.1.7-py3-none-any.whl (950 kB)\n", | |
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m950.8/950.8 kB\u001b[0m \u001b[31m12.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | |
"\u001b[?25hRequirement already satisfied: absl-py in /usr/local/lib/python3.10/dist-packages (from keras-nlp>=0.4.0->autokeras) (1.4.0)\n", | |
"Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from keras-nlp>=0.4.0->autokeras) (1.23.5)\n", | |
"Requirement already satisfied: regex in /usr/local/lib/python3.10/dist-packages (from keras-nlp>=0.4.0->autokeras) (2023.6.3)\n", | |
"Requirement already satisfied: rich in /usr/local/lib/python3.10/dist-packages (from keras-nlp>=0.4.0->autokeras) (13.7.0)\n", | |
"Requirement already satisfied: dm-tree in /usr/local/lib/python3.10/dist-packages (from keras-nlp>=0.4.0->autokeras) (0.1.8)\n", | |
"Collecting tensorflow-text (from keras-nlp>=0.4.0->autokeras)\n", | |
" Downloading tensorflow_text-2.15.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.2 MB)\n", | |
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.2/5.2 MB\u001b[0m \u001b[31m27.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | |
"\u001b[?25hRequirement already satisfied: keras in /usr/local/lib/python3.10/dist-packages (from keras-tuner>=1.1.0->autokeras) (2.14.0)\n", | |
"Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from keras-tuner>=1.1.0->autokeras) (2.31.0)\n", | |
"Collecting kt-legacy (from keras-tuner>=1.1.0->autokeras)\n", | |
" Downloading kt_legacy-1.0.5-py3-none-any.whl (9.6 kB)\n", | |
"Requirement already satisfied: astunparse>=1.6.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (1.6.3)\n", | |
"Requirement already satisfied: flatbuffers>=23.5.26 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (23.5.26)\n", | |
"Requirement already satisfied: gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (0.5.4)\n", | |
"Requirement already satisfied: google-pasta>=0.1.1 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (0.2.0)\n", | |
"Requirement already satisfied: h5py>=2.9.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (3.9.0)\n", | |
"Requirement already satisfied: libclang>=13.0.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (16.0.6)\n", | |
"Requirement already satisfied: ml-dtypes==0.2.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (0.2.0)\n", | |
"Requirement already satisfied: opt-einsum>=2.3.2 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (3.3.0)\n", | |
"Requirement already satisfied: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (3.20.3)\n", | |
"Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (67.7.2)\n", | |
"Requirement already satisfied: six>=1.12.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (1.16.0)\n", | |
"Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (2.3.0)\n", | |
"Requirement already satisfied: typing-extensions>=3.6.6 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (4.5.0)\n", | |
"Requirement already satisfied: wrapt<1.15,>=1.11.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (1.14.1)\n", | |
"Requirement already satisfied: tensorflow-io-gcs-filesystem>=0.23.1 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (0.34.0)\n", | |
"Requirement already satisfied: grpcio<2.0,>=1.24.3 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (1.59.3)\n", | |
"Requirement already satisfied: tensorboard<2.15,>=2.14 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (2.14.1)\n", | |
"Requirement already satisfied: tensorflow-estimator<2.15,>=2.14.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow>=2.8.0->autokeras) (2.14.0)\n", | |
"Requirement already satisfied: python-dateutil>=2.8.1 in /usr/local/lib/python3.10/dist-packages (from pandas->autokeras) (2.8.2)\n", | |
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->autokeras) (2023.3.post1)\n", | |
"Requirement already satisfied: wheel<1.0,>=0.23.0 in /usr/local/lib/python3.10/dist-packages (from astunparse>=1.6.0->tensorflow>=2.8.0->autokeras) (0.42.0)\n", | |
"Requirement already satisfied: google-auth<3,>=1.6.3 in /usr/local/lib/python3.10/dist-packages (from tensorboard<2.15,>=2.14->tensorflow>=2.8.0->autokeras) (2.17.3)\n", | |
"Requirement already satisfied: google-auth-oauthlib<1.1,>=0.5 in /usr/local/lib/python3.10/dist-packages (from tensorboard<2.15,>=2.14->tensorflow>=2.8.0->autokeras) (1.0.0)\n", | |
"Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.10/dist-packages (from tensorboard<2.15,>=2.14->tensorflow>=2.8.0->autokeras) (3.5.1)\n", | |
"Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in /usr/local/lib/python3.10/dist-packages (from tensorboard<2.15,>=2.14->tensorflow>=2.8.0->autokeras) (0.7.2)\n", | |
"Requirement already satisfied: werkzeug>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from tensorboard<2.15,>=2.14->tensorflow>=2.8.0->autokeras) (3.0.1)\n", | |
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->keras-tuner>=1.1.0->autokeras) (3.3.2)\n", | |
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->keras-tuner>=1.1.0->autokeras) (3.6)\n", | |
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->keras-tuner>=1.1.0->autokeras) (2.0.7)\n", | |
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->keras-tuner>=1.1.0->autokeras) (2023.11.17)\n", | |
"Collecting namex (from keras-core->keras-nlp>=0.4.0->autokeras)\n", | |
" Downloading namex-0.0.7-py3-none-any.whl (5.8 kB)\n", | |
"Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich->keras-nlp>=0.4.0->autokeras) (3.0.0)\n", | |
"Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich->keras-nlp>=0.4.0->autokeras) (2.16.1)\n", | |
"Requirement already satisfied: tensorflow-hub>=0.13.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow-text->keras-nlp>=0.4.0->autokeras) (0.15.0)\n", | |
"Collecting tensorflow>=2.8.0 (from autokeras)\n", | |
" Downloading tensorflow-2.15.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (475.2 MB)\n", | |
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m475.2/475.2 MB\u001b[0m \u001b[31m2.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | |
"\u001b[?25hCollecting tensorboard<2.16,>=2.15 (from tensorflow>=2.8.0->autokeras)\n", | |
" Downloading tensorboard-2.15.1-py3-none-any.whl (5.5 MB)\n", | |
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.5/5.5 MB\u001b[0m \u001b[31m97.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | |
"\u001b[?25hCollecting tensorflow-estimator<2.16,>=2.15.0 (from tensorflow>=2.8.0->autokeras)\n", | |
" Downloading tensorflow_estimator-2.15.0-py2.py3-none-any.whl (441 kB)\n", | |
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m442.0/442.0 kB\u001b[0m \u001b[31m39.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | |
"\u001b[?25hCollecting keras (from keras-tuner>=1.1.0->autokeras)\n", | |
" Downloading keras-2.15.0-py3-none-any.whl (1.7 MB)\n", | |
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.7/1.7 MB\u001b[0m \u001b[31m90.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | |
"\u001b[?25hRequirement already satisfied: cachetools<6.0,>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from google-auth<3,>=1.6.3->tensorboard<2.15,>=2.14->tensorflow>=2.8.0->autokeras) (5.3.2)\n", | |
"Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.10/dist-packages (from google-auth<3,>=1.6.3->tensorboard<2.15,>=2.14->tensorflow>=2.8.0->autokeras) (0.3.0)\n", | |
"Requirement already satisfied: rsa<5,>=3.1.4 in /usr/local/lib/python3.10/dist-packages (from google-auth<3,>=1.6.3->tensorboard<2.15,>=2.14->tensorflow>=2.8.0->autokeras) (4.9)\n", | |
"Requirement already satisfied: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.10/dist-packages (from google-auth-oauthlib<1.1,>=0.5->tensorboard<2.15,>=2.14->tensorflow>=2.8.0->autokeras) (1.3.1)\n", | |
"Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich->keras-nlp>=0.4.0->autokeras) (0.1.2)\n", | |
"Requirement already satisfied: MarkupSafe>=2.1.1 in /usr/local/lib/python3.10/dist-packages (from werkzeug>=1.0.1->tensorboard<2.15,>=2.14->tensorflow>=2.8.0->autokeras) (2.1.3)\n", | |
"Requirement already satisfied: pyasn1<0.6.0,>=0.4.6 in /usr/local/lib/python3.10/dist-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard<2.15,>=2.14->tensorflow>=2.8.0->autokeras) (0.5.1)\n", | |
"Requirement already satisfied: oauthlib>=3.0.0 in /usr/local/lib/python3.10/dist-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<1.1,>=0.5->tensorboard<2.15,>=2.14->tensorflow>=2.8.0->autokeras) (3.2.2)\n", | |
"Installing collected packages: namex, kt-legacy, tensorflow-estimator, keras, keras-tuner, keras-core, tensorboard, tensorflow, tensorflow-text, keras-nlp, autokeras\n", | |
" Attempting uninstall: tensorflow-estimator\n", | |
" Found existing installation: tensorflow-estimator 2.14.0\n", | |
" Uninstalling tensorflow-estimator-2.14.0:\n", | |
" Successfully uninstalled tensorflow-estimator-2.14.0\n", | |
" Attempting uninstall: keras\n", | |
" Found existing installation: keras 2.14.0\n", | |
" Uninstalling keras-2.14.0:\n", | |
" Successfully uninstalled keras-2.14.0\n", | |
" Attempting uninstall: tensorboard\n", | |
" Found existing installation: tensorboard 2.14.1\n", | |
" Uninstalling tensorboard-2.14.1:\n", | |
" Successfully uninstalled tensorboard-2.14.1\n", | |
" Attempting uninstall: tensorflow\n", | |
" Found existing installation: tensorflow 2.14.0\n", | |
" Uninstalling tensorflow-2.14.0:\n", | |
" Successfully uninstalled tensorflow-2.14.0\n", | |
"Successfully installed autokeras-1.1.0 keras-2.15.0 keras-core-0.1.7 keras-nlp-0.6.3 keras-tuner-1.4.6 kt-legacy-1.0.5 namex-0.0.7 tensorboard-2.15.1 tensorflow-2.15.0 tensorflow-estimator-2.15.0 tensorflow-text-2.15.0\n" | |
] | |
} | |
], | |
"source": [ | |
"pip install autokeras" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# File: test_installation_autokeras.py\n", | |
"import tensorflow as tf\n", | |
"print(tf.__version__)" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "M2ntJXsFqTpJ", | |
"outputId": "3d47b859-3a04-48f4-c9aa-8c1985fedf36" | |
}, | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"2.15.0\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"from tensorflow.keras.datasets import mnist\n", | |
"import autokeras as ak\n", | |
"\n", | |
"# Load MNIST dataset\n", | |
"(x_train, y_train), (x_test, y_test) = mnist.load_data()\n", | |
"\n", | |
"# Normalize pixel values (between 0 and 1)\n", | |
"x_train = x_train.astype('float32') / 255.\n", | |
"x_test = x_test.astype('float32') / 255.\n", | |
"\n", | |
"# Reshape the data to have shape (batch_size, height, width, channels)\n", | |
"x_train = x_train.reshape(-1, 28, 28, 1)\n", | |
"x_test = x_test.reshape(-1, 28, 28, 1)\n", | |
"\n", | |
"# Initialize the image classifier.\n", | |
"clf = ak.ImageClassifier(max_trials=1)\n", | |
"\n", | |
"# Search for the best model.\n", | |
"clf.fit(x_train, y_train, epochs=1)\n", | |
"\n", | |
"# Evaluate on the testing data.\n", | |
"print('Test accuracy: ', clf.evaluate(x_test, y_test))" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "Gs050P08qdoU", | |
"outputId": "49a9fd61-0616-4e76-f5fa-1e71dc1569bd" | |
}, | |
"execution_count": 3, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Trial 1 Complete [00h 02m 10s]\n", | |
"val_loss: 0.06422781199216843\n", | |
"\n", | |
"Best val_loss So Far: 0.06422781199216843\n", | |
"Total elapsed time: 00h 02m 10s\n", | |
"1875/1875 [==============================] - 142s 75ms/step - loss: 0.1565 - accuracy: 0.9523\n", | |
"313/313 [==============================] - 6s 18ms/step - loss: 0.0681 - accuracy: 0.9766\n", | |
"Test accuracy: [0.06807347387075424, 0.9765999913215637]\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [], | |
"metadata": { | |
"id": "XlVRw3Fhqu6B" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment