nsml.save

nsml.save(checkpoint=None, save_fn=None)

The function that save model. nsml.bind() only defines a save function.

Parameters
  • str

    Every checkpoint receives a value to distinguish the model to be saved. The checkpoint value separates the model internally.

    The checkpoint value separates the model internally.If checkpoint is None, the model is saved with the name of the current time.If you save the same checkpoint twice, the contents will be overwritten.

  • save_fn (fn) –

    It receives function define the way of saving the model as an argument. The priority at which the save function is called is

    1. save_fn delivered to this function

    2. save function bound to nsml.bind()

    3. default save function defined in NSML

Example

def save(dir_path, **kwargs):
    torch.save(object, os.path.join(dir_path,'model.pth'))
    print('saved!')
nsml.save(checkpoint=checkpoint, save_fn=save)