Ejemplo n.º 1
0
 def make_summaries(self, env):
     with self.graph.as_default():
         if env.is_image():
             idx = T.random_uniform([], minval = 0, maxval = self.horizon - 1, dtype = T.int32)
             env.make_summary(self.q_O.get_parameters('regular')[0:1][:, idx], "reconstruction")
             env.make_summary(self.O[0:1][:, idx], "truth")
         self.summary = T.core.summary.merge_all()
Ejemplo n.º 2
0
def xavier(shape, constant=1):
    """ Xavier initialization of network weights"""
    fan_in, fan_out = get_fans(shape)
    low = -constant*np.sqrt(6.0/(fan_in + fan_out))
    high = constant*np.sqrt(6.0/(fan_in + fan_out))
    return T.random_uniform(shape,
                             minval=low, maxval=high,
                             dtype=T.floatx())
Ejemplo n.º 3
0
def uniform(shape, scale=0.05):
    return T.random_uniform(shape, minval=-scale, maxval=scale)
Ejemplo n.º 4
0
 def _sample(self, num_samples):
     shape = self.shape()
     sample_shape = T.concat([[num_samples], shape], 0)
     random_sample = T.random_uniform(sample_shape)
     m, b = Stats.X(self.m), Stats.X(self.b)
     return m[None] - b[None] * T.log(-T.log(random_sample))