-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
939372d
commit d73bc0c
Showing
7 changed files
with
59 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
from string import ascii_lowercase | ||
|
||
from tricycle_v2.tensor import Tensor | ||
from tricycle_v2.binary import bsub | ||
from tricycle_v2.reduce import radd | ||
from tricycle_v2.tensor import Tensor | ||
|
||
|
||
def mean_squared_error(y_true: Tensor, y_pred: Tensor) -> Tensor: | ||
""" | ||
Calcuate the mean square error along the final index of a tensor | ||
""" | ||
square_error = (y_true - y_pred) ** 2 | ||
square_error = (y_true - y_pred)**2 | ||
indices = ascii_lowercase[: len(square_error.shape)] | ||
subscript = f"{indices}->{indices[:-1]}" | ||
total_error = radd(square_error, subscript) | ||
return total_error / y_true.shape[-1] | ||
return total_error / square_error.shape[-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters