tf-keras-skeleton.py 文件源码

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

项目:LIE 作者: EmbraceLife 项目源码 文件源码
def random_uniform_variable(shape, low, high, dtype=None, name=None, seed=None):
      """Instantiates a variable with values drawn from a uniform distribution.

      Arguments:
          shape: Tuple of integers, shape of returned Keras variable.
          low: Float, lower boundary of the output interval.
          high: Float, upper boundary of the output interval.
          dtype: String, dtype of returned Keras variable.
          name: String, name of returned Keras variable.
          seed: Integer, random seed.

      Returns:
          A Keras variable, filled with drawn samples.

      Example:
      ```python
          # TensorFlow example
          >>> kvar = K.random_uniform_variable((2,3), 0, 1)
          >>> kvar
          <tensorflow.python.ops.variables.Variable object at 0x10ab40b10>
          >>> K.eval(kvar)
          array([[ 0.10940075,  0.10047495,  0.476143  ],
                 [ 0.66137183,  0.00869417,  0.89220798]], dtype=float32)
"""
  if dtype is None:
    dtype = floatx()
  shape = tuple(map(int, shape))
  tf_dtype = _convert_string_dtype(dtype)
  if seed is None:
    # ensure that randomness is conditioned by the Numpy RNG
    seed = np.random.randint(10e8)
  value = init_ops.random_uniform_initializer(
      low, high, dtype=tf_dtype, seed=seed)(shape)
  return variable(value, dtype=dtype, name=name)

```

评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号