Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. # hard sample mining?
  2.  
  3. net = build_net()
  4.  
  5. for i in range(NUM_ITERATIONS):
  6.  
  7.     anchors, positives, negatives = next(batch_generator)
  8.  
  9.     loss = net.evaluate([anchors, positives, negatives])
  10.  
  11.     loss_and_data = zip(loss, anchors, positives, negatives)
  12.  
  13.     loss_and_data = sorted(loss_and_data)
  14.  
  15.     batch_for_weight_update = loss_and_data[:batch_size]
  16.    
  17.     loss_hard, anchors_hard, positives_hard, negatives_hard = zip(*batch_for_weight_update)
  18.    
  19.     stuff = net.train_on_batch([anchors_hard, positives_hard, negatives_hard])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement