zoukankan      html  css  js  c++  java
  • tensorflow 关于打印 Tensor 对象的具体值(python)

    import tensorflow as tf
    x = tf.Variable(3, name='x')
    y = x * 5
    print(y)

    这个时候输出的是: Tensor("mul:0", shape=(), dtype=int32) ,并不是预料中的15,那么怎么输出15呢?如下:

    import tensorflow as tf
    import os
    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
    x = tf.Variable(3, name='x')
    y = x * 5
    sess = tf.InteractiveSession()
    sess.run(tf.global_variables_initializer())

    # Add print operation
    #x = tf.Print(x, [x], message="This is x: ")

    # Add more elements of the graph using a
    #b = tf.add(x,x).eval()
    print(x.eval())
    print(y.eval())
  • 相关阅读:
    水利行业传感器
    含水量传感器
    水位传感器
    物联网实践
    SQLCMD
    zigbee
    物联网支撑平台
    近距通信技术比较
    物联网发展
    NFC标签
  • 原文地址:https://www.cnblogs.com/junblog/p/10621059.html
Copyright © 2011-2022 走看看