Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Changelog

## v0.2.1
## v0.2.2

- Fixed a bug where `SequentialBuilder`could not do full batch training.
- Added Hinge and Huber loss.
- Crash fix for Huber and Hinge loss.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "phitodeep"
version = "0.2.1"
version = "0.2.2"
authors = [
{ name = "Ralph Dugue", email = "ralph@phito.dev" }
]
Expand Down
4 changes: 2 additions & 2 deletions src/phitodeep/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self) -> None:
super().__init__("Hinge")

def loss_func(self, y_pred, y_true):
return np.maximum(0, 1 - y_pred * y_true)
return np.mean(np.maximum(0, 1 - y_pred * y_true))

def loss_gradient(self, y_pred, y_true):
yz = y_pred * y_true
Expand All @@ -75,7 +75,7 @@ def loss_func(self, y_pred, y_true):
error = y_true - y_pred
L1 = error ** 2 / 2
L2 = self.delta * (np.abs(error) - (self.delta / 2))
return np.where(np.abs(error) > self.delta, L1, L2)
return np.mean(np.where(np.abs(error) > self.delta, L1, L2))

def loss_gradient(self, y_pred, y_true):
error = y_pred - y_true
Expand Down
Loading