tf-keras-skeleton.py 文件源码

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

项目:LIE 作者: EmbraceLife 项目源码 文件源码
def cast(x, dtype):
      """Casts a tensor to a different dtype and returns it.

      You can cast a Keras variable but it still returns a Keras tensor.

      Arguments:
          x: Keras tensor (or variable).
          dtype: String, either (`'float16'`, `'float32'`, or `'float64'`).

      Returns:
          Keras tensor with dtype `dtype`.

      Example:
      ```python
          >>> from keras import backend as K
          >>> input = K.placeholder((2, 3), dtype='float32')
          >>> input
          <tf.Tensor 'Placeholder_2:0' shape=(2, 3) dtype=float32>
          # It doesn't work in-place as below.
          >>> K.cast(input, dtype='float16')
          <tf.Tensor 'Cast_1:0' shape=(2, 3) dtype=float16>
          >>> input
          <tf.Tensor 'Placeholder_2:0' shape=(2, 3) dtype=float32>
          # you need to assign it.
          >>> input = K.cast(input, dtype='float16')
          >>> input
          <tf.Tensor 'Cast_2:0' shape=(2, 3) dtype=float16>
"""
  return math_ops.cast(x, dtype)


# UPDATES OPS

```

评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号