ntm_encdec.py 文件源码

python
阅读 21 收藏 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

        # sample the memorybook
        p_dis         = self.Prior()
        l             = T.iscalar()
        u             = self.rng.uniform((l, p_dis.shape[-2], p_dis.shape[-1]))
        binarybook    = T.cast(u <= p_dis, dtype=theano.config.floatX)
        memorybook    = self.Trans(binarybook)

        self.take     = theano.function([l], [binarybook, memorybook], name='take_action')

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


问题


面经


文章

微信
公众号

扫码关注公众号