Coder Social home page Coder Social logo

Comments (2)

mapengsen avatar mapengsen commented on July 28, 2024 1

Ok, thank you very much for your reply. I'll study it carefully and then try it. Thank you very much.

from transgan.

asarigun avatar asarigun commented on July 28, 2024

Hi @mapengsen,

I didn't use any breakpoints during training; however, you can do the following at train.py from this blog which I directly put here. I hope this will be helpful for you;

First set two parameters:

start_epoch: The number of epochs to start training during renewal
resume: Whether to implement breakpoint resume training

start_epoch = 0
resume = True

After the model and optimizer are set up, add the following code, load the checkpoint and then train,

if opt.resume:
   if os.path.isfile('checkpoint'):
       checkpoint = torch.load('checkpoint')
       start_epoch = checkpoint['epoch'] + 1
       model.load_state_dict(checkpoint['model'])
       optimizer.load_state_dict(checkpoint['optimizer'])
       print("=> loaded checkpoint (epoch {})".format(checkpoint['epoch']))
   else:
       print("=> no checkpoint found")

After each round of training and saving the model, add the following code to save the epoch, model, and optimizer information to the checkpoint file.

checkpoint = {
            'epoch': epoch,
            'model': model.state_dict(),
            'optimizer': optimizer.state_dict(),
        }
        torch.save(checkpoint,'checkpoint')

This method also supports the tensorboardX visualized breakpoint continuation graph, but it will generate an extra log file, which only records the situation after the breakpoint. The data after the breakpoint will continue to be recorded in the original log file.

from transgan.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.