Skip to content
Snippets Groups Projects

Implementation of Deep Learning unit tests, as well as paths to the 2d data for windows users in the UNet jupyter notebook.

Merged ofhkr requested to merge DL_unittests into main
1 file
+ 6
3
Compare changes
  • Side-by-side
  • Inline
+ 6
3
@@ -66,13 +66,15 @@ def train_model(model, hyperparameters, train_loader, val_loader, eval_every = 1
inputs, targets = data
inputs = inputs.to(device)
if device == 'cuda':
if torch.cuda.is_available():
targets = targets.to(device).type(torch.cuda.FloatTensor).unsqueeze(1)
else:
targets = targets.to(device).type(torch.FloatTensor).unsqueeze(1)
optimizer.zero_grad()
outputs = model(inputs)
loss = criterion(outputs, targets)
# Backpropagation
@@ -99,7 +101,7 @@ def train_model(model, hyperparameters, train_loader, val_loader, eval_every = 1
inputs, targets = data
inputs = inputs.to(device)
if device == 'cuda':
if torch.cuda.is_available():
targets = targets.to(device).type(torch.cuda.FloatTensor).unsqueeze(1)
else:
targets = targets.to(device).type(torch.FloatTensor).unsqueeze(1)
@@ -206,7 +208,8 @@ def inference(data,model):
pass
else:
raise ValueError("Input image must be (C,H,W) format")
model.to(device)
model.eval()
# Make new list such that possible augmentations remain identical for all three rows
Loading