zoukankan      html  css  js  c++  java
  • ubuntu16.04的Anaconda下的tensorflow安装py3.5

    一、下载Anaconda,安装。

    sudo bash Ana...........sh

    二、配置环境变量

    加最后一句:/home/py/Ana/bin 就是安装地址

    安装完毕reboot。

    输入python。看见Anaconda就对了

    三、conda环境

    创建一个PY3.5版本的名为tensorflow的环境

    这里官网说用默认的源。其使用我下面推荐的那个比较快一点。。

    conda install -n tensortflow -c https://conda.anaconda.org/jjhelmus tensorflow

    IPython,高级Python运行环境

    现已更名为Jupyter(http://jupyter.org/),支持通过notebook进行算法模型的共享。

    Spark,高性能并行计算环境

    从 https://conda.anaconda.org/anaconda-cluster 可以访问到集成的Spark版本。

    安装:

    conda install -n tensor -c https://conda.anaconda.org/anaconda-cluster spark

     

    TensorFlow,机器学习引擎

    TensorFlow是由Google开源的基于神经网络的机器学习引擎,从 https://www.tensorflow.org/ 访问详细信息。

    安装:

    conda install -n tensor -c https://conda.anaconda.org/jjhelmus tensorflow

    四、测试
    官网上的测试程序。对一个线性数据进行训练的demo
    import tensorflow as tf
    import numpy as np
    
    # Create 100 phony x, y data points in NumPy, y = x * 0.1 + 0.3
    x_data = np.random.rand(100).astype(np.float32)
    y_data = x_data * 0.1 + 0.3
    
    # Try to find values for W and b that compute y_data = W * x_data + b
    # (We know that W should be 0.1 and b 0.3, but TensorFlow will
    # figure that out for us.)
    W = tf.Variable(tf.random_uniform([1], -1.0, 1.0))
    b = tf.Variable(tf.zeros([1]))
    y = W * x_data + b
    
    # Minimize the mean squared errors.
    loss = tf.reduce_mean(tf.square(y - y_data))
    optimizer = tf.train.GradientDescentOptimizer(0.5)
    train = optimizer.minimize(loss)
    
    # Before starting, initialize the variables.  We will 'run' this first.
    init = tf.initialize_all_variables()
    
    # Launch the graph.
    sess = tf.Session()
    sess.run(init)
    
    # Fit the line.
    for step in range(201):
        sess.run(train)
        if step % 20 == 0:
            print(step, sess.run(W), sess.run(b))
    
    # Learns best fit is W: [0.1], b: [0.3]

    这个就是是py3的直接可以跑

    Ubuntu上推荐大家还是用sublime来写代码。

    结果

  • 相关阅读:
    异常空格处理
    django
    django的ORM理解
    Django前后端分离
    Django企业项目实战
    Centos7 从 git version 1.8.3.1升级git version 2.32.0 全过程
    代码 80070005 Windows Uudate 遇到未知错误
    Power Shell Active Directory 批量创建分组
    H3C S5024E-PWR-X 端口镜像及抓包实例
    FusionCompute 忘记密码 重置操作
  • 原文地址:https://www.cnblogs.com/MnsterLu/p/5846702.html
Copyright © 2011-2022 走看看