Casts a labeled tensor to a new type. Args: labeled_tensor: The input tensor. dtype: The type of the returned tensor. name: Optional op name. Returns: A labeled tensor with the new dtype.
(labeled_tensor, dtype=None, name=None)
| 1170 | @tc.accepts(core.LabeledTensorLike, |
| 1171 | tc.Optional(dtypes.DType), tc.Optional(string_types)) |
| 1172 | def cast(labeled_tensor, dtype=None, name=None): |
| 1173 | """Casts a labeled tensor to a new type. |
| 1174 | |
| 1175 | Args: |
| 1176 | labeled_tensor: The input tensor. |
| 1177 | dtype: The type of the returned tensor. |
| 1178 | name: Optional op name. |
| 1179 | |
| 1180 | Returns: |
| 1181 | A labeled tensor with the new dtype. |
| 1182 | """ |
| 1183 | with ops.name_scope(name, 'lt_cast', [labeled_tensor]) as scope: |
| 1184 | labeled_tensor = core.convert_to_labeled_tensor(labeled_tensor) |
| 1185 | op = math_ops.cast(labeled_tensor.tensor, dtype=dtype, name=scope) |
| 1186 | return core.LabeledTensor(op, labeled_tensor.axes) |
| 1187 | |
| 1188 | |
| 1189 | @tc.returns(core.LabeledTensor) |