From 42320421a253ffc07dca5afafc5b0c6858794872 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Sun, 11 Jun 2023 13:58:01 +0300 Subject: [PATCH] Fix model names in examples are inconsistent --- examples/advanced/execute_remotely_example.py | 10 +++++++--- examples/frameworks/pytorch/pytorch_abseil.py | 2 +- examples/frameworks/pytorch/pytorch_mnist.py | 5 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/examples/advanced/execute_remotely_example.py b/examples/advanced/execute_remotely_example.py index 52cebf78..757f28e3 100644 --- a/examples/advanced/execute_remotely_example.py +++ b/examples/advanced/execute_remotely_example.py @@ -7,14 +7,17 @@ make sure code doesn't crash, and then move to a stronger machine for the entire """ from __future__ import print_function + import argparse import os from tempfile import gettempdir + import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms + from clearml import Task, Logger @@ -51,7 +54,7 @@ def train(args, model, device, train_loader, optimizer, epoch): "train", "loss", iteration=(epoch * len(train_loader) + batch_idx), value=loss.item()) print('Train Epoch: {} [{}/{} ({:.0f}%)]\tLoss: {:.6f}'.format( epoch, batch_idx * len(data), len(train_loader.dataset), - 100. * batch_idx / len(train_loader), loss.item())) + 100. * batch_idx / len(train_loader), loss.item())) def test(args, model, device, test_loader, epoch): @@ -127,8 +130,9 @@ def main(): task.execute_remotely(queue_name="default") train(args, model, device, train_loader, optimizer, epoch) test(args, model, device, test_loader, epoch) - if (args.save_model): - torch.save(model.state_dict(), os.path.join(gettempdir(), "mnist_cnn.pt")) + + if args.save_model: + torch.save(model.state_dict(), os.path.join(gettempdir(), "mnist_cnn_remote.pt")) if __name__ == '__main__': diff --git a/examples/frameworks/pytorch/pytorch_abseil.py b/examples/frameworks/pytorch/pytorch_abseil.py index 92722ced..54f1335c 100644 --- a/examples/frameworks/pytorch/pytorch_abseil.py +++ b/examples/frameworks/pytorch/pytorch_abseil.py @@ -156,7 +156,7 @@ def main(_): test(FLAGS, model, device, test_loader, epoch) if FLAGS.save_model: - torch.save(model.state_dict(), os.path.join(gettempdir(), "mnist_cnn.pt")) + torch.save(model.state_dict(), os.path.join(gettempdir(), "mnist_cnn_abseil.pt")) if __name__ == "__main__": diff --git a/examples/frameworks/pytorch/pytorch_mnist.py b/examples/frameworks/pytorch/pytorch_mnist.py index 8f4cca19..d361d243 100644 --- a/examples/frameworks/pytorch/pytorch_mnist.py +++ b/examples/frameworks/pytorch/pytorch_mnist.py @@ -1,6 +1,7 @@ # ClearML - Example of Pytorch mnist training integration # from __future__ import print_function + import argparse import os from tempfile import gettempdir @@ -47,7 +48,7 @@ def train(args, model, device, train_loader, optimizer, epoch): "train", "loss", iteration=(epoch * len(train_loader) + batch_idx), value=loss.item()) print('Train Epoch: {} [{}/{} ({:.0f}%)]\tLoss: {:.6f}'.format( epoch, batch_idx * len(data), len(train_loader.dataset), - 100. * batch_idx / len(train_loader), loss.item())) + 100. * batch_idx / len(train_loader), loss.item())) def test(args, model, device, test_loader, epoch): @@ -128,7 +129,7 @@ def main(): train(args, model, device, train_loader, optimizer, epoch) test(args, model, device, test_loader, epoch) - if (args.save_model): + if args.save_model: torch.save(model.state_dict(), os.path.join(gettempdir(), "mnist_cnn.pt"))