rn_rnn_model.py 文件源码

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

项目:rngru 作者: rneilson 项目源码 文件源码
def loadfromfile(cls, infile):
        """Load model parameters from file and rebuild model."""

        with np.load(infile) as f:
            # Extract hyperparams and position
            p = f['p']
            hparams = pickle.loads(p.tobytes())
            hyper, epoch, pos = hparams['hyper'], hparams['epoch'], hparams['pos']

            # Load matrices
            pvalues = { n:f[n] for n in cls.pnames }

            # Create instance
            if isinstance(infile, str):
                stdout.write("Loaded model parameters from {0}\n".format(infile))
            stdout.write("Rebuilding model...\n")
            model = cls(hyper, epoch, pos, pvalues)

            return model
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号