File size: 687 Bytes
02dbcad | 1 2 3 4 5 6 7 8 9 | from pathlib import Path
import sys,numpy as np,torch
ROOT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(ROOT))
from model.rise_unet import *
c=load_config(ROOT);ck=torch.load(ROOT/c["paths"]["checkpoint"],map_location="cpu",weights_only=True);m=RISEUNet(**ck["model_config"]);m.load_state_dict(ck["model"]);m.train();x,t=synthetic_initialization(20);pred=[]
with torch.no_grad():
for w in range(5):o=m(x)[-1];pred.append(o[:,0].numpy());x=torch.cat((x[:,1:],o),1)
p=ROOT/c["paths"]["predictions"];p.parent.mkdir(parents=True,exist_ok=True);np.savez_compressed(p,ensemble=np.stack(pred,1),target=t.numpy(),lead_weeks=np.arange(1,6),dropout_ensemble=np.bool_(True));print(p)
|