as_tensor: as_tensor

Description Usage Arguments Value Examples

View source: R/generics.R

Description

Coerce objects to tensorflow tensors (potentially of a specific dtype). The provided default methods will call tf.convert_to_tensor and tf.cast as appropriate.

Usage

1
2
3
4
5
6
7
as_tensor(x, dtype = NULL, ..., name = NULL)

## Default S3 method:
as_tensor(x, dtype = NULL, ..., name = NULL)

## S3 method for class 'double'
as_tensor(x, dtype = NULL, ..., name = NULL)

Arguments

x

object to convert

dtype

NULL, a tensorflow dtype (tf$int32), or something coercible to one (e.g. a string "int32")

...,

ignored

name

NULL or a string. Useful for debugging in graph mode, ignored while in eager mode.

Value

a tensorflow tensor

Examples

1
2
3
4
5
## Not run: 
as_tensor(42, "int32")
as_tensor(as_tensor(42))

## End(Not run)

tensorflow documentation built on Aug. 20, 2021, 1:11 a.m.