当前位置: 首页>>代码示例>>Python>>正文


Python tensorflow.random_gamma方法代码示例

本文整理汇总了Python中tensorflow.random_gamma方法的典型用法代码示例。如果您正苦于以下问题:Python tensorflow.random_gamma方法的具体用法?Python tensorflow.random_gamma怎么用?Python tensorflow.random_gamma使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow的用法示例。


在下文中一共展示了tensorflow.random_gamma方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testShape

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import random_gamma [as 别名]
def testShape(self):
    # Fully known shape.
    rnd = tf.random_gamma([150], 2.0)
    self.assertEqual([150], rnd.get_shape().as_list())
    rnd = tf.random_gamma([150], 2.0, beta=[3.0, 4.0])
    self.assertEqual([150, 2], rnd.get_shape().as_list())
    rnd = tf.random_gamma([150], tf.ones([1, 2, 3]))
    self.assertEqual([150, 1, 2, 3], rnd.get_shape().as_list())
    rnd = tf.random_gamma([20, 30], tf.ones([1, 2, 3]))
    self.assertEqual([20, 30, 1, 2, 3], rnd.get_shape().as_list())
    rnd = tf.random_gamma([123], tf.placeholder(tf.float32, shape=(2,)))
    self.assertEqual([123, 2], rnd.get_shape().as_list())
    # Partially known shape.
    rnd = tf.random_gamma(tf.placeholder(tf.int32, shape=(1,)), tf.ones([7, 3]))
    self.assertEqual([None, 7, 3], rnd.get_shape().as_list())
    rnd = tf.random_gamma(tf.placeholder(tf.int32, shape=(3,)), tf.ones([9, 6]))
    self.assertEqual([None, None, None, 9, 6], rnd.get_shape().as_list())
    # Unknown shape.
    rnd = tf.random_gamma(tf.placeholder(tf.int32), tf.placeholder(tf.float32))
    self.assertIs(None, rnd.get_shape().ndims)
    rnd = tf.random_gamma([50], tf.placeholder(tf.float32))
    self.assertIs(None, rnd.get_shape().ndims) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:24,代码来源:random_gamma_test.py

示例2: _sample

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import random_gamma [as 别名]
def _sample(self, n_samples):
        samples = tf.random_gamma([n_samples], self.alpha,
                                  beta=1, dtype=self.dtype)
        return samples / tf.reduce_sum(samples, -1, keepdims=True) 
开发者ID:thu-ml,项目名称:zhusuan,代码行数:6,代码来源:multivariate.py

示例3: _sample

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import random_gamma [as 别名]
def _sample(self, n_samples):
        return tf.random_gamma([n_samples], self.alpha,
                               beta=self.beta, dtype=self.dtype) 
开发者ID:thu-ml,项目名称:zhusuan,代码行数:5,代码来源:univariate.py

示例4: _Sampler

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import random_gamma [as 别名]
def _Sampler(self, num, alpha, beta, dtype, use_gpu, seed=None):

    def func():
      with self.test_session(use_gpu=use_gpu, graph=tf.Graph()) as sess:
        rng = tf.random_gamma([num], alpha, beta=beta, dtype=dtype, seed=seed)
        ret = np.empty([10, num])
        for i in xrange(10):
          ret[i, :] = sess.run(rng)
      return ret

    return func 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:13,代码来源:random_gamma_test.py

示例5: testNoCSE

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import random_gamma [as 别名]
def testNoCSE(self):
    """CSE = constant subexpression eliminator.

    SetIsStateful() should prevent two identical random ops from getting
    merged.
    """
    for dtype in tf.float16, tf.float32, tf.float64:
      for use_gpu in [False, True]:
        with self.test_session(use_gpu=use_gpu):
          rnd1 = tf.random_gamma([24], 2.0, dtype=dtype)
          rnd2 = tf.random_gamma([24], 2.0, dtype=dtype)
          diff = rnd2 - rnd1
          self.assertGreater(np.linalg.norm(diff.eval()), 0.1) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:15,代码来源:random_gamma_test.py

示例6: _get_histogram_var_by_type

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import random_gamma [as 别名]
def _get_histogram_var_by_type(self,
                                   histogram_type,
                                   shape,
                                   name=None,
                                   **kwargs):
        with tf.name_scope(name, "get_hist_{}".format(histogram_type)):
            if histogram_type == "normal":
                # Make a normal distribution, with a shifting mean
                mean = tf.Variable(kwargs['mean'])
                stddev = tf.Variable(kwargs['stddev'])
                return tf.random_normal(
                    shape=shape, mean=mean, stddev=stddev), [mean, stddev]
            elif histogram_type == "gamma":
                # Add a gamma distribution
                alpha = tf.Variable(kwargs['alpha'])
                return tf.random_gamma(shape=shape, alpha=alpha), [alpha]
            elif histogram_type == "poisson":
                lam = tf.Variable(kwargs['lam'])
                return tf.random_poisson(shape=shape, lam=lam), [lam]
            elif histogram_type == "uniform":
                # Add a uniform distribution
                maxval = tf.Variable(kwargs['maxval'])
                return tf.random_uniform(shape=shape, maxval=maxval), [maxval]

            raise Exception('histogram type error %s' % histogram_type,
                            'builtin type', self._histogram_distribute_list) 
开发者ID:rlworkgroup,项目名称:gym-sawyer,代码行数:28,代码来源:tensorboard_output.py

示例7: random_gamma

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import random_gamma [as 别名]
def random_gamma(self, shape, alpha, beta=None):
        return tf.random_gamma(shape, alpha, beta=beta)
        pass 
开发者ID:sharadmv,项目名称:deepx,代码行数:5,代码来源:tensorflow.py

示例8: _sample

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import random_gamma [as 别名]
def _sample(self, alpha, beta):
        gammas = tf.random_gamma(shape=self.shape, alpha=alpha, beta=beta)
        return gammas 
开发者ID:davmre,项目名称:elbow,代码行数:5,代码来源:elementary.py

示例9: sample_pi

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import random_gamma [as 别名]
def sample_pi(self, alpha, beta):
        Gam = tf.random_gamma([1], alpha=alpha, beta=beta, name="Gam", seed=None)[0]
        return self.G_inv(Gam, alpha, beta)

    # shape augmentation 
开发者ID:PreferredAI,项目名称:cornac,代码行数:7,代码来源:pcrl.py

示例10: random_exponential

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import random_gamma [as 别名]
def random_exponential(shape, rate=1.0, dtype=tf.float32, seed=None):
  """
  Helper function to sample from the exponential distribution, which is not
  included in core TensorFlow.
  """
  return tf.random_gamma(shape, alpha=1, beta=1. / rate, dtype=dtype, seed=seed) 
开发者ID:tensorflow,项目名称:cleverhans,代码行数:8,代码来源:utils_tf.py


注:本文中的tensorflow.random_gamma方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。