我想填充此字典,因爲我循環,但是當我打印它檢查時,它似乎只有被添加到字典中的唯一元素是最後一項循環。如何才能做到這一點?如何使用循環填充Python字典
probabilities = {}
with tf_Session(graph=graph) as sess:
results = sess.run(output_operation.outputs[0],
{input_operation.outputs[0]:t})
results = np.squeeze(results)
top_k = results.argsort()[-5:][::-1]
labels = load_labels(label_files)
for j in top_k:
print(labels[j], results[j])
probabilities = {labels[j]:results[j]}
print (probabilities)
'概率[標籤[J] =結果[J]' – Alexander