Training LSTM for time series prediction with nan labels
I suggest implementing it this way : 


Set the nan value to 0 or any other value
when compiling keras model use parameter sample_weight_mode='temporal'
You can use masking on top of this by supplying the weight as the mask (sequence of values 1 if not nan 0 otherwise).


The steps above should give you the desired result.