Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. # Iterate examples
  2. Y = map_fn(a, X)
  3. answer = reduce_sum(Y, axis=0)
  4. # where X is your supplied tensor.
  5.  
  6.  
  7. # KNN
  8. xThresholded = tf.clip_by_value(tf.cast(x, tf.int32), 0, 1)
  9. yThresholded = tf.clip_by_value(tf.cast(y, tf.int32), 0, 1)
  10. computeL0Dist = tf.count_nonzero(xThresholded - yThresholded, axis[1,2])
  11. findKClosestTrImages = tf.contrib.framework.argsort(computeL0Dist, direction='ASCENDING')
  12. findLabelsKClosestTrImages = tf.gather(trLabels, findClosestTrImages[0:paramk])
  13. findULabels, findIndex, findCounts = tf.unique_with_counts(findLabelsKClosestTrImages)
  14. findPredictedLabel = tf.gather(findULabels, tf.argmax(findCounts))
  15. findULabels, findIndex, findCounts = tf.unique_with_counts(top_all_label)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement