zoukankan      html  css  js  c++  java
  • Tensorflow学习教程创建图启动图

    参考博客:https://www.cnblogs.com/cnugis/p/7635128.html
    视频链接:https://www.bilibili.com/video/av20542427?from=search&seid=3218324014806772997

     Tensorflow作为目前最热门的机器学习框架之一,受到了工业界和学界的热门追捧。以下几章教程将记录本人学习tensorflow的一些过程。

      在tensorflow这个框架里,可以讲是弱数据类型,也就是说不严格声明数据是什么类型,因为在整个过程中玩的都是向量,或者说矩阵和数组,所有的数据都被看做是一个tensor, 一个或者几个tensor经过一个op(operation)之后,产生新的tensor。首先将所有tensor和op都定义好,然后把这套tensor和op的组合放到默认的图里,用会话启动图,最后我们就看到结果了。以下是创建图和启动图的代码以及结果。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    #coding:utf-8
    import tensorflow as tf
    m1 = tf.constant([[3,3]])
    m2 = tf.constant([[2],[3]])
    product = tf.matmul(m1,m2)
    print (product)
    #定义一个会话 启动默认图
    sess = tf.Session()
    #调用sess的run方法来执行矩阵乘法
    result = sess.run(product)
    print (result)
    sess.close()

      结果如下

    复制代码
    I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
    I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
    I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
    I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
    I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
    Tensor("MatMul:0", shape=(1, 1), dtype=int32)
    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
    I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties: 
    name: GeForce GTX 1080 Ti
    major: 6 minor: 1 memoryClockRate (GHz) 1.582
    pciBusID 0000:03:00.0
    Total memory: 10.91GiB
    Free memory: 10.24GiB
    I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0 
    I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0:   Y 
    I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:03:00.0)
    [[15]]
  • 相关阅读:
    OD调试1--第一个win32程序
    Koa与Node.js开发实战(1)——Koa安装搭建(视频演示)
    《11招玩转网络安全》之第五招:DVWA命令注入
    《11招玩转网络安全》之第四招:low级别的DVWA SQL注入
    一张图11招学会Python网络黑客
    《11招玩转网络安全》之第三招:Web暴力破解-Low级别
    《11招玩转网络安全》之第二招:漏洞扫描
    《11招玩转网络安全》之第一招:Docker For Docker
    11招玩转黑客攻防——用Python,更安全
    如何有效的练习并且提升写代码的能力?
  • 原文地址:https://www.cnblogs.com/shuimuqingyang/p/9960749.html
Copyright © 2011-2022 走看看