當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。