trainable_em.py 文件源码

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

项目:crayimage 作者: yandexdataschool 项目源码 文件源码
def gen(self, normal_mu_range, anomaly_mu_range):
    self.gens = [
      compound_distribution(
        stats.uniform(loc=anomaly_mu_range[0], scale=anomaly_mu_range[1] - anomaly_mu_range[0]),
        truncated(stats.poisson, max_value=1024)
      ),

      compound_distribution(
        stats.uniform(loc=normal_mu_range[0], scale=normal_mu_range[1] - normal_mu_range[0]),
        truncated(stats.poisson, max_value=1024)
      )
    ]

    self.priors = np.array([0.1, 0.9])

    n = 100
    m = 10
    bins = 64
    MC = CameraMC(self.priors, self.gens, image_shape=(1, n, ), n_frames=100, max_value=bins)

    X = np.ndarray(shape=(m, n, bins), dtype='float32')
    cats = np.ndarray(shape=(m, n), dtype='float32')

    for i in xrange(m):
      cats[i], _, imgs = MC.get_sample()
      h = ndcount(imgs, bins=bins)
      print h.shape
      h = h.reshape(n, bins)

      X[i] = h.astype('float32') / np.sum(h, axis=1)[:, None]

    print("X shape %s" % (X.shape, ))
    print("Categories shape %s" % (cats.shape, ))

    self.X = X
    self.cats = cats
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号