【问题标题】:How to print the number of tensor in tensorflow [duplicate]如何在tensorflow中打印张量的数量[重复]
【发布时间】:2023-04-02 08:18:01
【问题描述】:

inception/inception_eval.py,我想打印标签和logits。

我尝试了一些方法,但它们不起作用。
我怎样才能得到这些张量的数量?

  with tf.Graph().as_default():
# Get images and labels from the dataset.

# with tf.Session() as sess:
#   images, labels = image_processing.inputs(dataset)
#   print ("lable")
#   sess.run (labels.eval())
images, labels = image_processing.inputs(dataset)
# sess = tf.Session()
# print("lable")
# print (labels)
# Number of classes in the Dataset label set plus 1.
# Label 0 is reserved for an (unused) background class.
num_classes = dataset.num_classes() + 1

# Build a Graph that computes the logits predictions from the
# inference model.
logits, _ = inception.inference(images, num_classes)
print ("logits")
# print (tf.cast(logits,tf.float32).eval())
# print ("_")
# print (tf.cast(_,tf.float32).eval())

【问题讨论】:

标签: python tensorflow computer-vision


【解决方案1】:

如果您检查 inception_model 文件,您会看到 inference function 返回两个张量:

逻辑。二维浮点张量。

辅助逻辑。的二维浮点张量 侧头。仅用于训练。

所以你只需要创建一个会话并在这个会话中运行这个张量。

【讨论】:

    猜你喜欢
    • 2017-11-10
    • 2016-09-01
    • 2016-02-11
    • 2017-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-15
    相关资源
    最近更新 更多