Skip to content

Commit

Permalink
utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Shreyasi2002 committed Dec 20, 2023
1 parent dfb2e1b commit 123e087
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@ def load_checkpoint(checkpoint, model, optimizer):
return checkpoint['train_losses'], checkpoint['val_losses']

def save_checkpoint(checkpoint, model_path):
torch.save(checkpoint, model_path)
torch.save(checkpoint, model_path)

def to_numpy_array(tensor):
'''Convert torch.Tensor to np.ndarray'''
tensor_ = tensor.cpu()
tensor_ = tensor_.squeeze(0)
tensor_ = tensor_.detach().numpy()
return tensor_

0 comments on commit 123e087

Please sign in to comment.