"...text-generation-inference.git" did not exist on "b0b97fd9a7d549421eadc1ab574f060a8e114b9c"
Commit c6f12863 authored by Billy Lamberta's avatar Billy Lamberta
Browse files

Add snippet for get_started index page.

parent 1f82c227
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "_index.ipynb",
"version": "0.3.2",
"views": {},
"default_view": {},
"provenance": []
}
},
"cells": [
{
"metadata": {
"id": "rX8mhOLljYeM",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"##### Copyright 2018 The TensorFlow Authors.\n",
"\n",
"Licensed under the Apache License, Version 2.0 (the \"License\");"
]
},
{
"metadata": {
"id": "BZSlp3DAjdYf",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
},
"cellView": "form"
},
"cell_type": "code",
"source": [
"#@title Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"#\n",
"# https://www.apache.org/licenses/LICENSE-2.0\n",
"#\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License."
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "3wF5wszaj97Y",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"# Get Started with TensorFlow\n",
"\n",
"First, import TensorFlow into your program:"
]
},
{
"metadata": {
"id": "0trJmd6DjqBZ",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
},
"cell_type": "code",
"source": [
"import tensorflow as tf"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "7NAbSZiaoJ4z",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"Load and configure the [MNIST](http://yann.lecun.com/exdb/mnist/) dataset. Convert the samples from an int to a float:"
]
},
{
"metadata": {
"id": "7FP5258xjs-v",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
},
"cell_type": "code",
"source": [
"mnist = tf.keras.datasets.mnist\n",
"\n",
"(X_train, y_train), (X_test, y_test) = mnist.load_data()\n",
"\n",
"X_train, X_test = X_train / 255.0, X_test / 255.0"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "BPZ68wASog_I",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"Build the `tf.keras` model:"
]
},
{
"metadata": {
"id": "rBO43XtLjhCd",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
},
"cell_type": "code",
"source": [
"model = tf.keras.models.Sequential([\n",
" tf.keras.layers.Flatten(),\n",
" tf.keras.layers.Dense(512, activation='relu'),\n",
" tf.keras.layers.Dropout(0.2),\n",
" tf.keras.layers.Dense(10, activation='softmax')\n",
"])\n",
"\n",
"model.compile(optimizer='adam', \n",
" loss='sparse_categorical_crossentropy',\n",
" metrics=['accuracy'])"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "ix4mEL65on-w",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"Train and evaluate model:"
]
},
{
"metadata": {
"id": "cQnPHobsj0td",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
},
"cell_type": "code",
"source": [
"model.fit(X_train, y_train, epochs=5)\n",
"\n",
"model.evaluate(X_test, y_test)"
],
"execution_count": 0,
"outputs": []
}
]
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment