【问题标题】:mnist-score for GANs on mnist data-set returns a logits tensor of [batch, 10]mnist 数据集上 GAN 的 mnist-score 返回 [batch, 10] 的 logits 张量
【发布时间】:2020-02-26 20:57:49
【问题描述】:

我使用this code 来计算mnist-score(初始分数)。 函数mnist_score 将分数作为张量返回。如何将其转换为浮点数?

def mnist_score(images, graph_def_filename=None, input_tensor=INPUT_TENSOR,
                output_tensor=OUTPUT_TENSOR, num_batches=1):
  """Get MNIST logits of a fully-trained classifier.
  Args:
    images: A minibatch tensor of MNIST digits. Shape must be
      [batch, 28, 28, 1].
    graph_def_filename: Location of a frozen GraphDef binary file on disk. If
      `None`, uses a default graph.
    input_tensor: GraphDef's input tensor name.
    output_tensor: GraphDef's output tensor name.
    num_batches: Number of batches to split `generated_images` in to in order to
      efficiently run them through Inception.
  Returns:
    A logits tensor of [batch, 10].
  """
  images.shape.assert_is_compatible_with([None, 28, 28, 1])

  graph_def = _graph_def_from_par_or_disk(graph_def_filename)
  mnist_classifier_fn = lambda x: tfgan.eval.run_image_classifier(  # pylint: disable=g-long-lambda
      x, graph_def, input_tensor, output_tensor)

  score = tfgan.eval.classifier_score(
      images, mnist_classifier_fn, num_batches)
  score.shape.assert_is_compatible_with([])

  return score

【问题讨论】:

    标签: python python-3.x tensorflow deep-learning generative-adversarial-network


    【解决方案1】:

    需要注意的一点是,初始分数在 MNIST 上几乎没有意义。它计算 logits 并查看这些 logits 的分布。然而,数字甚至不是 ImageNet 中的类,因此使用预先训练的网络将导致任意输出。

    除此之外,您可以使用会话并使用 sess.run(score) 运行该会话来评估 tensorflow 中的张量,或者如果您在会话中,则可以使用 score.eval()。根据图像是占位符还是固定张量,您可能还需要将图像输入到方法中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-01
      • 1970-01-01
      • 2014-12-02
      • 1970-01-01
      • 2020-11-02
      • 2020-05-25
      • 2016-09-13
      • 1970-01-01
      相关资源
      最近更新 更多