Guest User

Untitled

a guest
Dec 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. def train(num_iteration):
  2. global total_iterations
  3.  
  4. for i in range(total_iterations,
  5. total_iterations + num_iteration):
  6.  
  7. x_batch, y_true_batch, _, cls_batch = data.train.next_batch(batch_size)
  8. x_valid_batch, y_valid_batch, _, valid_cls_batch = data.valid.next_batch(batch_size)
  9.  
  10.  
  11. feed_dict_tr = {x: x_batch,
  12. y_true: y_true_batch}
  13. feed_dict_val = {x: x_valid_batch,
  14. y_true: y_valid_batch}
  15.  
  16. session.run(optimizer, feed_dict=feed_dict_tr)
  17.  
  18. if i % int(data.train.num_examples/batch_size) == 0:
  19. val_loss = session.run(cost, feed_dict=feed_dict_val)
  20. epoch = int(i / int(data.train.num_examples/batch_size))
  21.  
  22. show_progress(epoch, feed_dict_tr, feed_dict_val, val_loss)
  23. saver.save(session, 'dogs-cats-model')
  24.  
  25.  
  26. total_iterations += num_iteration
Add Comment
Please, Sign In to add comment