TensorFlow Action(开山使用篇)
1、TensorFlow安装:
使用pip install tensorflow安装CPU版;
或使用pip install tensorflow-gpu==1.2.1指定版本安装GPU版。
2、TensorFlow测试样例:
import tensorflow as tf
a = tf.constant([1.0, 2.0], name="a")
b = tf.constant([3.0, 4.0], name="b")
add = a + b
sess = tf.Session()
sess.run(add)
使用python的import操作加载TensorFlow;
使用tf.constant函数定义两个常量tensor,并将两个tensor相加;
使用tf.Session函数生成一个会话(session)并通过这个session来计算结果;
以上若运行无误,则说明TensorFlow安装成功。
3、TensorFlow指定GPU占用 示例:
import os
import tensorflow as tf
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = ""
config = tf.ConfigProto()
# 设置定量的GPU使用量,占用GPU50%的显存
# config.gpu_options.per_process_gpu_memory_fraction = 0.5
# 设置最小的GPU使用量,自动增长:按需求分配显存
config.gpu_options.allow_growth = True
# 打印详细日志信息
config.log_device_placement = True
a = tf.constant([1.0, 2.0], name="a")
b = tf.constant([3.0, 4.0], name="b")
add = a + b
with tf.Session(config=config) as sess:
sess.run(add)
使用os.environ指定具体的GPU,指定GPU占用可参考TensorFlow指定GPU使用及监控GPU占用情况
使用tf.ConfigProto()函数设置config设定GPU使用量及tf的其他属性参数,并在tf.Session()中指定该config。
TensorFlow Action(开山使用篇)的更多相关文章
- [翻译] TensorFlow 分布式之论文篇 "TensorFlow : Large-Scale Machine Learning on Heterogeneous Distributed Systems"
[翻译] TensorFlow 分布式之论文篇 "TensorFlow : Large-Scale Machine Learning on Heterogeneous Distributed ...
- [翻译] TensorFlow 分布式之论文篇 "Implementation of Control Flow in TensorFlow"
[翻译] TensorFlow 分布式之论文篇 "Implementation of Control Flow in TensorFlow" 目录 [翻译] TensorFlow ...
- salesforce lightning零基础学习(十) Aura Js 浅谈三: $A、Action、Util篇
前两篇分别介绍了Component类以及Event类,此篇将会说一下 $A , Action以及 Util. 一. Action Action类通常用于和apex后台交互,设置参数,调用后台以及对结 ...
- [Android Pro] AndroidStudio IDE界面插件开发(进阶篇之Action机制)
转载请注明出处:[huachao1001的专栏:http://blog.csdn.net/huachao1001/article/details/53883500] 从上一篇<AndroidSt ...
- [源码解析] TensorFlow 分布式 DistributedStrategy 之基础篇
[源码解析] TensorFlow 分布式 DistributedStrategy 之基础篇 目录 [源码解析] TensorFlow 分布式 DistributedStrategy 之基础篇 1. ...
- Struts2第二篇【开发步骤、执行流程、struts.xml讲解、defalut-struts讲解】
前言 我们现在学习的是Struts2,其实Struts1和Struts2在技术上是没有很大的关联的.Struts2其实基于Web Work框架的,只不过它的推广没有Struts1好,因此就拿着Stru ...
- Struts2入门这一篇就够了
前言 这是Strtus的开山篇,主要是引入struts框架...为什么要引入struts,引入struts的好处是什么,以及对Struts2一个简单的入门.... 为什么要引入struts? 既然Se ...
- 双显卡笔记本安装CUDA+theano、tensorflow环境
原文出处:http://www.cnblogs.com/jacklu/p/6377820.html 个人知乎主页欢迎关注:https://www.zhihu.com/people/jack_lu,相信 ...
- 统计学习方法:罗杰斯特回归及Tensorflow入门
作者:桂. 时间:2017-04-21 21:11:23 链接:http://www.cnblogs.com/xingshansi/p/6743780.html 前言 看到最近大家都在用Tensor ...
随机推荐
- EasyMvc入门教程-基本控件说明(7)文字块导航
文字块导航其实就是开发winform时候常见的 带Title的Group面板..~!@#¥..好吧,没开发过winform的同学看下图: 实现代码如下: @Html.Q().BlockField(). ...
- 140. Word Break II(hard)
欢迎fork and star:Nowcoder-Repository-github 140. Word Break II 题目: Given a non-empty string s and a d ...
- Python 可视化Twitter中指定话题中Tweet的词汇频率
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-8 @author: guaguastd @name: pl ...
- GUID概念
GUID概念 GUID: 即Globally Unique Identifier(全球唯一标识符) 也称作 UUID(Universally Unique IDentifier) . GUID是 ...
- 利用window.navigator.userAgent判断当前是否微信内置浏览器
<!DOCTYPE HTML> <html lang="en"> <head> <meta charset="utf-8&quo ...
- 多系统启动光盘制作---WIN7+WinXP+老毛桃PE工具箱
1.工具: ⑴ Windows 7 ISO: ⑵ Windows XP ISO: ⑶ 老毛桃U盘启动盘制作工具V2013 制作得的ISO (含PE.DOS等): ⑷ UltraISO.EasyBoot ...
- JS创建表单提交备份
//保存 function saveFT() { var data = { createDate: GetDateStr(0), name: $("#txtName").val() ...
- 程序猿的量化交易之路(32)--Cointrade之Portfolio组合(19)
转载须注明出处:http://blog.csdn.net/minimicall?viewmode=contents,http://cloudtrade.top/ Portfolio:组合,代表的是多个 ...
- js的常用小技巧
//类对象转成数组 var domNodes = Array.prototype.slice.call(document.getElementsByTagName("*")); ...
- AI生万物,新世界的大门已敞开
四月是万物复苏的时节,一年一度的GMIC全球移动互联网大会也在这个时间如期而至,在4月26日-28日的会议期间,有超过三百位行业专家进行了精彩的演讲,更有数万名现场观众感受到思维碰撞迸发出的火花. 作 ...