tf-keras-skeleton.py 文件源码

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

项目:LIE 作者: EmbraceLife 项目源码 文件源码
def ones(shape, dtype=None, name=None):
      """Instantiates an all-ones tensor variable and returns it.

      Arguments:
          shape: Tuple of integers, shape of returned Keras variable.
          dtype: String, data type of returned Keras variable.
          name: String, name of returned Keras variable.

      Returns:
          A Keras variable, filled with `1.0`.

      Example:
      ```python
          >>> from keras import backend as K
          >>> kvar = K.ones((3,4))
          >>> K.eval(kvar)
          array([[ 1.,  1.,  1.,  1.],
                 [ 1.,  1.,  1.,  1.],
                 [ 1.,  1.,  1.,  1.]], dtype=float32)
"""
  if dtype is None:
    dtype = floatx()
  shape = tuple(map(int, shape))
  tf_dtype = _convert_string_dtype(dtype)
  return variable(
      init_ops.constant_initializer(1., dtype=tf_dtype)(shape), dtype, name)

```

评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号