TensorFlow 张量投射

2018-09-08 15:28 更新

tf.cast

cast (  
    x ,  
    dtype ,  
    name = None
  )

定义在:tensorflow/python/ops/math_ops.py

参见指南:张量变换>铸造

将张量投射到新的类型.

该操作将 x(在张量的情况下)或 x.values(在 SparseTensor 情况下)投射到 dtype.

例如:

#tensor`a` is [1.8,2.2],dtype = tf.float  
tf.cast(a, tf.int32 ) == >  [ 1 , 2 ]   #dtype = tf.int32

ARGS:

  • x:一个张量或 SparseTensor.
  • dtype:目标类型.
  • name:操作的名称(可选).

返回:

与 x 具有相同形状的张量或 SparseTensor.

注意:

  • TypeError:当 x 不能投射到 dtype.


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy