zoukankan      html  css  js  c++  java
  • Python机器学习之TensorFlow

    (一)准备

    1.  TensorFlow官方网址:www.tensorflow.org
    2.  GitHub网址:github.com/tensorflow/tensorflow
    3.  模型仓库网址:github.com/tensorflow/models
    4. 支持此语言:python,C++,Go, Java, 后端使用C++、CUDA
    5. 安装:pip install --upgrade tensorflow==1.14.0

    (二)核心:

    1.  TensorFlow中的计算可以表示为一个有向图(Directed Graph),其中RNN是DAG
    2.  或者称计算图(Computation Graph)
    3.  其中每一个运算操作(operation)将作为一个节点(node)
    4.  计算图描述了数据的计算流程,也负责维护和更新状态
    5.  用户通过python,c++,go,Java语言设计这个这个数据计算的有向图
    6.  计算图中每一个节点可以有任意多个输入和任意多个输出
    7.  每一个节点描述了一种运算操作,节点可以算是运算操作的实例化(instance)
    8.  计算图中的边里面流动(flow)的数据被称为张量(tensor),故得名TensorFlow

    (三)代码流程

    Import tensorflow as tf
    
    b = tf.Variable(tf.zeros([100]))       #b为w0是一个向量
    W = tf.Variable(tf.random_uniform([784,100], -1, 1))     #W为变量,uniform:均匀分布,从均匀分布中随机取值784行100列
    x = tf.placeholder(name=“x”)              #placeholder:占位符
    relu = tf.nn.relu(tf.matmul(W, x) + b)     #激活函数,matmul矩阵相乘再加b,对线性结果进行非线性变化
    Cost = […]                                 #不同算法值不同
    Sess = tf.Session()                        #开始执行算法
    for step in range(0, 10):                  
      input = …construct 100-D input array…         #创建input
      result = sess.run(cost, feed_dict={x: input})
      print(step, result)                     #打印结果

    kkk

  • 相关阅读:
    android工程下assets与raw文件夹
    eclipse增加jar包方式对比
    跳出内循环,继续下一次外循环的写法
    ImportError: cannot import name 'BaseDataset' from 'src.dataset'
    神经网络中的反向传播法
    Pytorch中ndarray tensor list互转
    Python运行语法错误:IndentationError: unindent does not match any outer indentation level
    module 'torch' has no attribute 'gesv'
    极大似然估计
    Gaussian Processes
  • 原文地址:https://www.cnblogs.com/lq13035130506/p/12575007.html
Copyright © 2011-2022 走看看