ntm_encdec.py 文件源码

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

项目:CopyNet 作者: MultiPath 项目源码 文件源码
def compile_sample(self):
        # for Typical Auto-encoder, only conditional generation is useful.
        inputs        = T.imatrix()  # padded input word sequence (for training)
        if self.config['mode']   == 'RNN':
            context   = alloc_zeros_matrix(inputs.shape[0], self.config['enc_contxt_dim'])
        elif self.config['mode'] == 'NTM':
            context   = T.repeat(self.memory[None, :, :], inputs.shape[0], axis=0)
        else:
            raise NotImplementedError
        pass

        # encoding
        memorybook    = self.encoder.build_encoder(inputs, context)
        self.memorize = theano.function([inputs], memorybook, name='memorize')

        # compile the sampler.
        self.decoder.build_sampler()
        logger.info('sampler function compile done.')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号