tf rps loss function
I'm the xarray
and data
guy with only little experience in ML. Still I try to produce some ML-based 2020 forecasts myself (without competing for the prizes).
The organizers are convinced that a goal of this competition is to foster discussions about ML and S2S. So let me start...
Do you think a tensorflow loss function rps
would be useful for training? Or should rps
rather be a metric?
import tensorflow as tf
def rps_loss(y_true, y_pred, sample_weight=None):
y_true = tf.one_hot(tf.cast(y_true,'int32'), depth=3) # depends on data generator used before
Fc = tf.cumsum(y_pred, axis=-1)
Oc = tf.cumsum(y_true, axis=-1)
diff = tf.subtract(Fc, Oc)
rps = tf.reduce_sum(tf.square(diff), axis=-1)
# mask ocean
y_one = tf.reduce_sum(y_true, axis=-1)
rps = tf.multiply(rps, y_one)
# spatial mean # todo add weights
return rps
A related question is about the NaN
s in the ground truth training data. Doesn't that basically mean that the model can do what ever it wants over ocean?
Where I played around with this: https://renkulab.io/gitlab/aaron.spring/s2s-ai-challenge-template/-/blob/ML_probabilistic/notebooks/ML_train_and_predict.ipynb