Python mnist数据集上GANs的mnist分数返回[batch,10]的logits张量
我用来计算mnist分数(初始分数)。 函数Python mnist数据集上GANs的mnist分数返回[batch,10]的logits张量,python,python-3.x,tensorflow,deep-learning,generative-adversarial-network,Python,Python 3.x,Tensorflow,Deep Learning,Generative Adversarial Network,我用来计算mnist分数(初始分数)。 函数mnist\u 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. Arg
mnist\u 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
需要注意的一点是,《盗梦空间》的分数在MNIST上没有什么意义。它计算logit并查看这些logit的分布。然而,数字在ImageNet中不是偶数类,因此使用预先训练的网络将导致任意输出 除此之外,您可以使用会话并使用
sess.run(score)
运行该会话,或者如果您在会话中,您可以使用score.eval()
来计算tensorflow中的张量。根据图像是占位符还是固定张量,您可能还需要将图像输入到方法中