In [0]:
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
学习目标:在浏览器中运行 TensorFlow 程序。
以下代码块为“Hello World”TensorFlow 程序。
其中包含初始化代码(导入 TensorFlow 模块并启用“eager execution”,我们将在后续练习中详细介绍此操作),然后输出“Hello, world!”字符串常量。
In [0]:
from __future__ import print_function
import tensorflow as tf
try:
tf.contrib.eager.enable_eager_execution()
except ValueError:
pass # enable_eager_execution errors after its first call
tensor = tf.constant('Hello, world!')
tensor_value = tensor.numpy()
print(tensor_value)