zoukankan      html  css  js  c++  java
  • 109、TensorFlow计算张量的值

    # 当计算图创建成功时
    # 你就可以运行这个计算图,然后生成一个新的张量
    # 并且得到这个张量指向的计算图中具体的数值
    #这个功能在debug的时候非常有必要
    #最简单获得张量具体值的方法是使用Tensor.eval method
    import tensorflow as tf
    constant = tf.constant([1, 2, 3])
    #进行点乘,对应位置的元素相乘
    tensor = constant * constant
    init = tf.global_variables_initializer()
    with tf.Session() as sess:
        sess.run(init)
        #eval方法只有当session开启的时候才好用
        #Tensor.eval 方法返回一个python的numpy对象,和原来的张量有着相同的值
        print(tensor.eval())

    下面是上面输出的张量的结果:

    2018-02-16 21:46:48.085119: I C:	f_jenkinsworkspace
    el-winMwindowsPY35	ensorflowcoreplatformcpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
    [1 4 9]
  • 相关阅读:
    bzoj3530 [SDOI2014]数数
    bzoj3940 Censoring
    线性代数基础
    hdu1085 Holding Bin-Laden Captive!
    hdu1028 Ignatius and the Princess III
    luogu2000 拯救世界
    博弈论入门
    树hash
    luogu2173 [ZJOI2012]网络
    luogu1501 [国家集训队]Tree II
  • 原文地址:https://www.cnblogs.com/weizhen/p/8450608.html
Copyright © 2011-2022 走看看