Skip to content

Commit

Permalink
Update crit.py for CPU LSTM
Browse files Browse the repository at this point in the history
  • Loading branch information
Yalan-Song authored Dec 1, 2023
1 parent b03a83b commit bda8a6e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions hydroDL/model/crit.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ def __init__(self, stdarray, eps=0.1):
def forward(self, output, target, igrid):
nt = target.shape[0]
stdse = np.tile(self.std[igrid].T, (nt, 1))
stdbatch = torch.tensor(stdse, requires_grad=False).float().cuda()
if torch.cuda.is_available():
stdbatch = torch.tensor(stdse, requires_grad=False).float().cuda()
else:
stdbatch = torch.tensor(stdse, requires_grad=False).float()
p0 = output[:, :, 0] # dim: Time*Gage
t0 = target[:, :, 0]
mask = t0 == t0
Expand All @@ -227,7 +230,10 @@ def __init__(self, stdarray, eps=0.1):
def forward(self, output, target, igrid):
nt = target.shape[0]
stdse = np.tile(self.std[igrid], (nt, 1))
stdbatch = torch.tensor(stdse, requires_grad=False).float().cuda()
if torch.cuda.is_available():
stdbatch = torch.tensor(stdse, requires_grad=False).float().cuda()
else:
stdbatch = torch.tensor(stdse, requires_grad=False).float()
p0 = output[:, :, 0] # dim: Time*Gage
t0 = target[:, :, 0]
mask = t0 == t0
Expand Down

0 comments on commit bda8a6e

Please sign in to comment.