Commit f982dfaf authored by Andrei-Claudiu Roibu's avatar Andrei-Claudiu Roibu 🖥
Browse files

debugging + commenting out functions deprecated

parent 92dfa3ee
......@@ -50,7 +50,7 @@ class Solver():
logs_directory (str): Directory for outputing training logs
Returns:
trained model(?) - working on this!
trained model - working on this!
"""
......@@ -105,8 +105,8 @@ class Solver():
self.start_epoch = 1
self.start_iteration = 1
self.best_mean_score = 0
self.best_mean_score_epoch = 0
# self.best_mean_score = 0
# self.best_mean_score_epoch = 0
self.LogWriter = LogWriter(number_of_classes=number_of_classes,
logs_directory=logs_directory,
......@@ -159,8 +159,8 @@ class Solver():
print('-> Phase: {}'.format(phase))
losses = []
outputs = []
y_values = []
# outputs = []
# y_values = []
if phase == 'train':
model.train()
......@@ -196,9 +196,11 @@ class Solver():
iteration += 1
losses.append(loss.item())
outputs.append(torch.max(y_hat, dim=1)[1].cpu())
y_values.append(y.cpu())
# outputs.append(torch.max(y_hat, dim=1)[1].cpu())
# y_values.append(y.cpu())
# Clear the memory
......@@ -212,24 +214,25 @@ class Solver():
print("100%", flush=True)
with torch.no_grad():
output_array, y_array = torch.cat(
outputs), torch.cat(y_values)
# output_array, y_array = torch.cat(
# outputs), torch.cat(y_values)
self.LogWriter.loss_per_epoch(losses, phase, epoch)
dice_score_mean = self.LogWriter.dice_score_per_epoch(
phase, output_array, y_array, epoch)
if phase == 'test':
if dice_score_mean > self.best_mean_score:
self.best_mean_score = dice_score_mean
self.best_mean_score_epoch = epoch
index = np.random.choice(
len(dataloaders[phase].dataset.X), size=3, replace=False)
self.LogWriter.sample_image_per_epoch(prediction=model.predict(dataloaders[phase].dataset.X[index], self.device),
ground_truth=dataloaders[phase].dataset.y[index],
phase=phase,
epoch=epoch)
# dice_score_mean = self.LogWriter.dice_score_per_epoch(
# phase, output_array, y_array, epoch)
# if phase == 'test':
# if dice_score_mean > self.best_mean_score:
# self.best_mean_score = dice_score_mean
# self.best_mean_score_epoch = epoch
# index = np.random.choice(
# len(dataloaders[phase].dataset.X), size=3, replace=False)
# self.LogWriter.sample_image_per_epoch(prediction=model.predict(dataloaders[phase].dataset.X[index], self.device),
# ground_truth=dataloaders[phase].dataset.y[index],
# phase=phase,
# epoch=epoch)
print("Epoch {}/{} DONE!".format(epoch, self.number_epochs))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment