Skip to content

Commit

Permalink
Add bool function to return whether a model contains loss
Browse files Browse the repository at this point in the history
Summary:
Add a function to return true if the model contains loss and retuen
false if the model doesn't include a loss.

Reviewed By: kittipatv

Differential Revision: D6982444

fbshipit-source-id: 1f63b7a1eaa3077841a0ad5d8d854b471d0aa84c
  • Loading branch information
sunnieshang authored and facebook-github-bot committed Feb 14, 2018
1 parent 83c4947 commit fd28e0f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions caffe2/python/layer_model_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ def loss(self, loss):
assert self._loss is None
self._loss = loss

def has_loss(self):
return self._loss is not None

def add_loss(self, loss, name='unnamed'):
assert loss is not None, "Added loss should not be None"
assert isinstance(loss, schema.Scalar) or isinstance(
Expand Down

0 comments on commit fd28e0f

Please sign in to comment.