【发布时间】: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