Python机器学习及实践——进阶篇:Tensorflow框架
Tensorflow内部有自己所定义的常量、变量、数据操作等要素。Tensorflow使用图(Graph)来表示计算任务;并使用会话(Session)来执行图。
使用Tensorflow输出一句话
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@File : TF01.py
@Author: Xinzhe.Pang
@Date : 2019/7/26 22:00
@Desc :
"""
# 导入tensorflow工具包并命名为tf
import tensorflow as tf
import numpy as np
# 初始化一个Tensorflow的常量:Open the door of Tensorflow! 字符串,并命名为greeting作为一个计算模块
greeting = tf.constant('Open the door of Tensorflow!')
# 启动一个绘画
sess = tf.Session()
# 使用会话执行greeting计算模块
result = sess.run(greeting)
# 输出会话结果
print(result)
# 关闭会话
sess.close()
2019-07-26 22:03:13.411070: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructi