Guest User

Untitled

a guest
Oct 19th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. images, captions = [], []
  2. bpg = bad_pair_generator(images, captions)
  3.  
  4. clfr = classifier()
  5. data = ([(1, img, cpt) for img, cpt in zip(images, captions)] +
  6. [(0, img, cpt) for img, cpt in bpg.generate(N)])
  7.  
  8. for epoch in range(epochs):
  9. good_pairs, bad_pairs = zip(images, captions), bpg.generate(N)
  10. X, y = good_pairs + bad_pairs, [1]*len(good_pairs) + [0]*len(bad_pairs)
  11.  
  12. clfr.train(X, y)
  13.  
  14. trickiness = [yi == yi_pred for yi, yi_pred in zip(y, clfr.predict(X))]
  15. bpg.fit(bad_pairs, trickiness[-len(bad_pairs):])
Add Comment
Please, Sign In to add comment