目录

1.git安装与使用

1.1 git安装

1.2 修改git bash默认路径

1.3 git常用操作

2.环境搭建

   2.1 tensorflow安装

   2.2 CUDA安装

   2.3 CuDNN安装

3.测试

3.1 helloword测试

3.2 简单线性回归测试


1.git安装与使用

1.1 git安装

1、从Git官网下载一个Git安装包,官网地址为:http://git-scm.com/downloads;
     2、一键安装,环境变量会自己配置好

1.2 修改git bash默认路径

  1. 开始菜单下找到Git Bash 快捷方式
  2. 选中Git Bash图标,右键,选中“属性”

  3. 去掉--cd-to-home,修改“起始位置”为自定义的git 本地仓库的路径,如:F:\git_code

1.3 git常用操作

1. 创建新仓库:创建文件夹,进入文件夹,执行git init 命令
      2. 检出仓库 :git clone username@host:/path/to/repository
      3. 从远程下载 1) git remote add origin git@github.com:demonxian3/hellowrold.git #关联本地和远程仓库
                             2) git pull origin master         #从远程把新变化拉下来
      4. 本地上传    1) git add your_resource          #从本地仓库增加,结果会保存到本机缓存里
                             2) git commit –m    “注释”                          #提交本机缓存的内容到本机HEAD里面
                             3)git push origin master          #把本地仓库提交到远程仓库 origin代表关联的远程仓库

2.环境搭建

2.1 tensorflow安装

1.pip install tensorflow

2.2 安装CUDA(是显卡厂商NVIDIA推出的运算平台)

1.打开链接https://developer.nvidia.com/cuda-toolkit-archive 找对应的版本下载 可以下local版(1.4G) 或者network    版 比较小
  2.安装后 检查环境变量 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin

2.3. 安装cuDNN(是用于深度神经网络的GPU加速库)

1.下载https://developer.nvidia.com/rdp/cudnn-download
  2.解压配置环境变量C:\Program Files\NVIDIA GPU Computing Toolkit\cudnn-9.0-windows10-x64-v7\cuda\bin

3.测试

3.1 helloword测试

  1.跑helloworld 发现警告 Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
  解释:1)为了提升CPU计算速度的。若你有支持cuda的GPU,则可以忽略这个问题,因为安装SSE4.1, SSE4.2, AVX, AVX2, FMA, 仅仅提升CPU的运算速度(大概有3倍)
  解决办法:
      1)忽视警告,并屏蔽警告
        开头输入如下:
        import os
        os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
      2)进 tensorflow 官网,从源码安装。

  2.代码

'''
HelloWorld example using TensorFlow library. Author: Aymeric Damien
Project: https://github.com/aymericdamien/TensorFlow-Examples/
''' from __future__ import print_function import tensorflow as tf # Simple hello world using TensorFlow # Create a Constant op
# The op is added as a node to the default graph.
#
# The value returned by the constructor represents the output
# of the Constant op.
hello = tf.constant('Hello, TensorFlow!') # Start tf session
sess = tf.Session() # Run the op
print(sess.run(hello))

3.2 简单线性回归测试

'''
@author :Eric-chen
@contact:809512722@qq.com
@time :2018/4/14 18:09
@desc :简单线性回归
'''
import tensorflow as tf
import numpy as np
import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' #create data
x_data=np.random.rand(100).astype(np.float32)
y_data=0.1*x_data+0.3 #create tensorflow structure start
Weights=tf.Variable(tf.random_uniform([1],-2.0,2.0))
biases=tf.Variable(tf.zeros([1])) y=Weights*x_data+biases
loss=tf.reduce_mean(tf.square(y-y_data)) optimizer=tf.train.GradientDescentOptimizer(0.4)
train=optimizer.minimize(loss) init=tf.global_variables_initializer()
#create tensorflow structure end sess=tf.Session()
#Very important
sess.run(init)
for step in range(2000):
sess.run(train)
if step%20 ==0:
print(step,sess.run(Weights),sess.run(biases))

  

参考资料:

1.Windows下修改Git Bash 默认路径
2.Git服务搭建及github使用教程
3.CPU、GPU、CUDA,CuDNN 简介

TensorFlow 从零到helloWorld的更多相关文章

  1. Netty入门(一):零基础“HelloWorld”详细图文步骤

    因为接下来的项目要用到netty,所以就了解一下这个程序,奈何网上的教程都是稍微有点基础的,所以,就写一篇对于netty零基础的,顺便也记录一下. 先扔几个参考学习的网页: netty 官方API:  ...

  2. 第20月第28天 tensorflow

    1. 505  sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade virtualenv 506   virt ...

  3. TensorFlow 入门 | iBooker·ApacheCN

    原文:Getting Started with TensorFlow 协议:CC BY-NC-SA 4.0 自豪地采用谷歌翻译 不要担心自己的形象,只关心如何实现目标.--<原则>,生活原 ...

  4. JS做深度学习1——偶然发现与入门

    JS做深度学习1--偶然发现与入门 不久前,我初次涉猎了Node.js,并且使用它开发了毕业设计的WEB模块,然后通过在Node中调用系统命令执行Python文件方式实现了深度学习功能模块的对接,Py ...

  5. ApacheCN 深度学习译文集 2020.9

    协议:CC BY-NC-SA 4.0 自豪地采用谷歌翻译 不要担心自己的形象,只关心如何实现目标.--<原则>,生活原则 2.3.c 在线阅读 ApacheCN 面试求职交流群 72418 ...

  6. TensorFlow入门,基本介绍,基本概念,计算图,pip安装,helloworld示例,实现简单的神经网络

    TensorFlow入门,基本介绍,基本概念,计算图,pip安装,helloworld示例,实现简单的神经网络

  7. android 从零单排 第一期 按键显示helloworld

    啦啦啦- 我是qscqesze 今天开始android的从零单排啦啦啦- 首先从最简单的开始 要求: 程序运行后,单击屏幕上的按键后可以显示一句话,如“Hello World!” 这是一个最基础最基础 ...

  8. TensorFlow安装和HelloWorld

    TensorFlow安装 TensorFlow可以在各种操作系统上面安装.安装的时候要注意TensorFlow的类型,一种是普通的版本,仅支持CPU,安装简单.另外一种类型带GPU的,可以利用GPU来 ...

  9. win10 安装 tensorflow 并运行helloworld

    win10 安装 tensorflow 并运行helloworld   折腾了一下,在win10上成功安装tensorflow. 1 下载安装python,注意一定要是64位(比如python-3.5 ...

随机推荐

  1. ES6实用新特性

    兼容性 http://kangax.github.io/compat-table/es5/ http://kangax.github.io/compat-table/es6/ ES6(ES2015)兼 ...

  2. Python 安装 imread报错

    看到一篇博客才解决 http://blog.csdn.net/u010480899/article/details/52701025

  3. hibernate 创建工厂类

    package cn.hibernate; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; / ...

  4. 3D开机动画

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name ...

  5. [财务知识]IFRS9

    浅谈IFRS9 2018-07-10 23:15信用/收益 原创申明 本文原创作者为金融监管研究院助理研究员李健,未经授权谢绝转载.引用.抄袭. 引言 2018年6月6日,财政部会计司发布了“关于就& ...

  6. Delphi cxGrid加行号

    procedure SetRowNumber(var ASender: TcxGridTableView; AViewInfo: TcxCustomGridIndicatorItemViewInfo; ...

  7. Codeforces Round #530 Div. 1 自闭记

    A:显然应该让未确定的大小尽量大.不知道写了啥就wa了一发. #include<iostream> #include<cstdio> #include<cmath> ...

  8. 01 Maven构建的项目中,把.xml等配置文件添加到编译目录

    Maven构建的项目,默认只会把src/main/resources目录下的xml配置文件添加到编译目录. 如果需要把src/main/java目录下的xml配置文件也添加到编译目录,需要在pom.x ...

  9. MT【111】画图估计

    评:此类方程是超越方程,一般情况下无法解出具体的解,常见手段:1.画图  2.猜根.此处可以取特殊值a=2.5,b=3.5,容易知道此时$x=2.5\in(2,3)$

  10. 40+ 个非常有用的 Oracle 查询语句

    40+ 个非常有用的 Oracle 查询语句,主要涵盖了日期操作,获取服务器信息,获取执行状态,计算数据库大小等等方面的查询.这些是所有 Oracle 开发者都必备的技能,所以快快收藏吧! 日期/时间 ...