-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: cleaned up base reward functions
- Loading branch information
Showing
7 changed files
with
98 additions
and
72 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import numpy as np | ||
|
||
|
||
def squared_norm(a: np.ndarray, weight: float = 1.0) -> np.ndarray: | ||
return np.sum(a ** 2, axis=-1) * weight | ||
|
||
|
||
def fd_first_order_squared_norm( | ||
a: np.ndarray, | ||
b: np.ndarray, | ||
weight: float = 1.0, | ||
) -> np.ndarray: | ||
return squared_norm(a - b, weight) | ||
|
||
|
||
def fd_second_order_squared_norm( | ||
a: np.ndarray, | ||
b: np.ndarray, | ||
c: np.ndarray, | ||
weight: float = 1.0, | ||
) -> np.ndarray: | ||
return squared_norm(a - 2 * b + c, weight) | ||
|
||
|
||
def exp_squared_norm(a: np.ndarray, mult: float = 1.0, weight: float = 1.0) -> np.ndarray: | ||
return np.exp(squared_norm(a), mult) * weight | ||
|
||
|
||
def exp_fd_first_order_squared_norm( | ||
a: np.ndarray, | ||
b: np.ndarray, | ||
mult: float = 1.0, | ||
weight: float = 1.0, | ||
) -> np.ndarray: | ||
return np.exp(mult * fd_first_order_squared_norm(a, b)) * weight | ||
|
||
|
||
def exp_fd_second_order_squared_norm( | ||
a: np.ndarray, | ||
b: np.ndarray, | ||
c: np.ndarray, | ||
mult: float = 1.0, | ||
weight: float = 1.0, | ||
) -> np.ndarray: | ||
return np.exp(mult * fd_second_order_squared_norm(a, b, c)) * weight |