ECMWFCode4Earth / ml_drought

Machine learning to better predict and understand drought. Moving github.com/ml-clim
https://ml-clim.github.io/drought-prediction/
90 stars 18 forks source link

Add prediction month to the models #53

Closed gabrieltseng closed 5 years ago

gabrieltseng commented 5 years ago

Adds the one hot encoded prediction month to the models, so they know which month they are predicting.

In addition, extends the chunker to handle an arbitrary number of x tensors / arrays.

gabrieltseng commented 5 years ago

Re: the experiment name, I think maybe we could think about that after your stuff is added?

But I agree that this is a pretty universal use case, so it might not be worth adding an extra folder just for this.

One additional note:

The deep explainer is currently failing with

File "/home/gabrieltseng95/miniconda3/envs/esowc-drought/lib/python3.7/site-packages/shap/explainers/deep/deep_pytorch.py", line 107, in <listcomp>
    grads = [torch.autograd.grad(selected, x)[0].cpu().numpy() for x in X]
  File "/home/gabrieltseng95/miniconda3/envs/esowc-drought/lib/python3.7/site-packages/torch/autograd/__init__.py", line 149, in grad
    inputs, allow_unused)
RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time.

I am not sure if this is a bug in this code, or in shap. I'll take a look, but merge this first to not block your stuff.

gabrieltseng commented 5 years ago

Turns out its a problem with shap; I'll try and fix it ASAP