Guest User

Untitled

a guest
Dec 7th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. class CustomLoss():
  2. def __init__(self, steps_per_epoch):
  3. super().__init__()
  4. self.steps_per_epoch = steps_per_epoch
  5. self.step = 0
  6.  
  7. def calc_custom_loss(self, y_true, y_pred):
  8. y_true1 = get_y_true1(self.step)
  9. y_true2 = get_y_true2(self.step)
  10.  
  11. self.step += 1
  12. self.step %= self.steps_per_epoch
  13.  
  14. # Assuming there are 100 batches in one epoch ...
  15. custom_loss = CustomLoss(steps_per_epoch=100)
  16. model.compile(loss=custom_loss.calc_custom_loss, ...)
Add Comment
Please, Sign In to add comment