2016-12-14 38 views

回答

0

假設您正在使用一個softmax分類器來選擇N個類作爲網絡的最後一層。僞代碼可能看起來像這樣,其中最後一層的批量大小爲其第一維:

# computation graph 
predictions = argmax(softmax(final_layer)) 
matches = predictions == argmax(labels) # if one-hot encoded 

# later 
batch_matches = sess.run(matches, feed_dict={...}) 

for image, does_match in zip(batch_images, batch_matches): 
    if not does_match: 
    cv2.imwrite('mismatched.png', image)