reader.py 文件源码

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

项目:crnn_tf 作者: liuhu-bigeye 项目源码 文件源码
def initiate_estimations(self):
        self.estimations.close()
        self.estimations = h5py.File(self.estimate_path, 'a')

        scale = 0.5
        eps = 1e-3
        # estimation shape (n_sample, max_h_len, max_t_len + 1)
        for idx in range(self.n_samples):
            token = self.tokens[idx]
            t_len = len(token)
            h_len = int(np.ceil(float(self.db['end_index'][idx] - self.db['begin_index'][idx] - self.c3d_depth) / float(self.depth_stride))) + 1

            steps = np.linspace(0, h_len-1, t_len)
            esti = [np.ones(h_len)[:, None]*eps] + [norm.pdf(np.arange(h_len)[:, None], loc=round(l), scale=scale) for l in steps]
            esti = np.hstack(esti)

            self.estimations[self.estimate_key][idx, :h_len, :t_len + 1] = copy.deepcopy(esti / esti.sum(axis=-1)[:, None] * 0.9)
        self.estimations.close()
        self.estimations = h5py.File(self.estimate_path, 'a')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号