のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

FileNotFoundError latest_net_G.pth

dataset [AlignedDataset] was created
initialize network with normal
model [Pix2PixModel] was created
loading the model from log_train/sub_20190130_1324/pix2pix_popRam/latest_net_G.pth
Traceback (most recent call last):
  File "pytorch-CycleGAN-and-pix2pix/test.py", line 47, in <module>
    model.setup(opt)               # regular setup: load and print networks; create schedulers
  File "/content/pytorch-CycleGAN-and-pix2pix/models/base_model.py", line 88, in setup
    self.load_networks(load_suffix)
  File "/content/pytorch-CycleGAN-and-pix2pix/models/base_model.py", line 187, in load_networks
    state_dict = torch.load(load_path, map_location=str(self.device))
  File "/usr/local/lib/python3.6/dist-packages/torch/serialization.py", line 365, in load
    f = open(f, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'log_train/sub_20190130_1324/pix2pix_popRam/latest_net_G.pth'

これかな?

 parser.add_argument('--save_latest_freq', type=int, default=5000, help='frequency of saving the latest results')
train.py
  if total_iters % opt.save_latest_freq == 0:   # cache our latest model every <save_latest_freq> iterations
                print('saving the latest model (epoch %d, total_iters %d)' % (epoch, total_iters))
                save_suffix = 'iter_%d' % total_iters if opt.save_by_iter else 'latest'
                model.save_networks(save_suffix)

github.com

これで、5epochごとに、saveしている。

 parser.add_argument('--save_epoch_freq', type=int, default=5, help='frequency of saving checkpoints at the end of epochs')

f:id:none53:20190202101433p:plain