nutszebra_chainer.py 文件源码

python
阅读 14 收藏 0 点赞 0 评论 0

项目:trainer 作者: nutszebra 项目源码 文件源码
def save_model(self, path=''):
        """Save chainer model

        Example:

        ::

            path = './test.model'
            self.save_model(path)

        Args:
            path (str): path

        Returns:
            bool: True if saving successful
        """

        # if gpu_flag is True, switch the model to gpu mode at last
        gpu_flag = False
        # if gpu mode, switch the model to cpu mode temporarily
        if self.model_is_cpu_mode() is False:
            self.to_cpu()
            gpu_flag = True
        # if path is ''
        if path == '':
            path = str(self.save_model_epoch) + '.model'
        self.nz_save_model_epoch += 1
        # increment self.nz_save_model_epoch
        serializers.save_npz(path, self)
        # if gpu_flag is True, switch the model to gpu mode at last
        if gpu_flag:
            self.to_gpu()
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号