{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "hello_world.ipynb", "version": "0.3.2", "views": {}, "default_view": {}, "collapsed_sections": ["JndnmDMp66FL"] } }, "cells": [ { "metadata": { "id": "JndnmDMp66FL", "colab_type": "text" }, "source": [ "#### Copyright 2017 Google LLC." ], "cell_type": "markdown" }, { "metadata": { "id": "hMqWDc_m6rUC", "colab_type": "code", "colab": { "autoexec": { "startup": false, "wait_interval": 0 } }, "cellView": "both" }, "source": [ "# 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." ], "cell_type": "code", "execution_count": 0, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "cH-YtyZs7Gcg", "colab_type": "text" }, "source": [ " # 准备工作:Hello World"]}, { "cell_type": "markdown", "metadata": { "id": "r0QBC2kTixPn", "colab_type": "text" }, "source": [ " **学习目标:**在浏览器中运行 TensorFlow 程序。"]}, { "cell_type": "markdown", "metadata": { "id": "33fL46pgixPo", "colab_type": "text" }, "source": [ " 以下是一个 \\'Hello World\\' TensorFlow 程序:"]}, { "metadata": { "id": "bRuPN7qo7ICp", "colab_type": "code", "colab": { "autoexec": { "startup": false, "wait_interval": 0 } }, "cellView": "both" }, "source": [ "import tensorflow as tf\n", "\n", "c = tf.constant('Hello, world!')\n", "\n", "with tf.Session() as sess:\n", "\n", " print sess.run(c)" ], "cell_type": "code", "execution_count": 0, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "Bl1nAshab6m5", "colab_type": "text" }, "source": [ " ## 要运行此程序,请执行以下操作\n", "\n", " 1. 点击代码块中的任意位置(例如,点击字词 `import`)。\n", "\n", " 2. 点击代码块左上角的右向三角图标,或按 ⌘/Ctrl+Enter 键。\n", "\n", " 程序需要几秒钟才会运行。如果一切顺利,程序会在代码块正下方显示 `Hello, world!` 字样\n", "\n", "整个程序仅包含一个代码块。不过,大部分练习都会包含多个代码块,在这种情况下,您应**按从上到下的顺序逐个运行代码块**。\n", "\n", "不按顺序运行代码块通常会导致错误。"]}, { "cell_type": "markdown", "metadata": { "id": "UpzZ0Gv-uKf_", "colab_type": "text" }, "source": [ " ## 实用的键盘快捷键\n", "\n", "* **⌘/Ctrl+m、b:**在当前选择的单元格下方创建一个空白代码单元格\n", "* **⌘/Ctrl+m、i:**中断单元格的运行\n", "* **⌘/Ctrl+m、h:**显示所有键盘快捷键列表\n", "* 要查看关于任何 TensorFlow API 方法的文档,请将光标放置在其左括号的正后方,然后按 **Tab** 键:\n", "\n", "![TensorFlow tf.constant 方法的弹出式文档](https://storage.googleapis.com/mledu-images/tf_constant_pop_up_doc.png)"]} ] }