Hello, can someone help me create a mean directional accuracy loss function for pytorch?
in numpy it should be this: https://gist.github.com/bshishov/5dc237f59f019b26145648e2124ca1c9 2
def mda(actual: np.ndarray, predicted: np.ndarray):
“”" Mean Directional Accuracy “”"
return np.mean((np.sign(actual[1:] - actual[:-1]) == np.sign(predicted[1:] - predicted[:-1])).astype(int))
but i get errors if use it as loss criterion in pytorch