TFloat16
Stay organized with collections
Save and categorize content based on your preferences.
IEEE-754 half-precision 16-bit float tensor type.
Since there is no floating-point type that fits in 16 bits in Java, a conversion (with
potentially a precision loss) is required for each 32 bits value written or read on a tensor of
this type from the JVM. Therefore, if a lot of I/O operations are to be expected on a tensor,
performances will be improved by working with TFloat32
or TFloat64
data types
whenever possible.
Also, TFloat16
tensors normally perform better if they are located in GPU memory since
most CPUs do not support this format natively. For CPU computation on 16-bit floats, the TBfloat16
tensor type might be a better option.
Public Methods
abstract
static
TFloat16
|
scalarOf(float value)
Allocates a new tensor for storing a single float value.
|
abstract
static
TFloat16
|
|
abstract
static
TFloat16
|
|
abstract
static
TFloat16
|
tensorOf( Shape shape, Consumer< TFloat16> dataInit)
Allocates a new tensor of the given shape and initialize its data.
|
abstract
static
TFloat16
|
tensorOf( NdArray<Float> src)
Allocates a new tensor which is a copy of a given array of floats.
|
abstract
static
TFloat16
|
vectorOf(float... values)
Allocates a new tensor for storing a vector of floats.
|
Inherited Methods
From interface
org.tensorflow.ndarray.NdArray
abstract
NdArray<Float>
|
copyTo( NdArray<Float> dst)
Copy the content of this array to the destination array.
|
abstract
NdArraySequence<? extends NdArray<T>>
|
elements(int dimensionIdx)
Returns a sequence of all elements at a given dimension.
|
abstract
boolean
|
equals(Object obj)
Checks equality between n-dimensional arrays.
|
abstract
NdArray<Float>
|
get(long... coordinates)
Returns the N-dimensional element of this array at the given coordinates.
|
abstract
Float
|
getObject(long... coordinates)
Returns the value of the scalar found at the given coordinates.
|
abstract
NdArray<Float>
|
read( DataBuffer<Float> dst)
Read the content of this N-dimensional array into the destination buffer.
|
abstract
NdArraySequence<? extends NdArray<T>>
|
scalars()
Returns a sequence of all scalars in this array.
|
abstract
NdArray<Float>
|
set( NdArray<Float> src, long... coordinates)
Assigns the value of the N-dimensional element found at the given coordinates.
|
abstract
NdArray<Float>
|
setObject(Float value, long... coordinates)
Assigns the value of the scalar found at the given coordinates.
|
abstract
NdArray<Float>
|
slice( Index... indices)
Creates a multi-dimensional view (or slice) of this array by mapping one or more dimensions
to the given index selectors.
|
abstract
NdArray<Float>
|
write( DataBuffer<Float> src)
Write the content of this N-dimensional array from the source buffer.
|
From interface
org.tensorflow.Tensor
abstract
RawTensor
|
asRawTensor()
Returns a raw (untyped) representation of this tensor
|
abstract
void
|
close()
Release resources associated with the Tensor.
|
abstract
DataType
|
|
abstract
long
|
numBytes()
Returns the size, in bytes, of the tensor data.
|
abstract
static
<T extends TType>
T
|
of(Class<T> type, Shape shape, long size, Consumer<T> dataInitializer)
Allocates a tensor of a given datatype, shape and size.
|
abstract
static
<T extends TType>
T
|
of(Class<T> type, Shape shape)
Allocates a tensor of a given datatype and shape.
|
abstract
static
<T extends TType>
T
|
of(Class<T> type, Shape shape, long size)
Allocates a tensor of a given datatype, shape and size.
|
abstract
static
<T extends TType>
T
|
of(Class<T> type, Shape shape, Consumer<T> dataInitializer)
Allocates and initialize a tensor of a given datatype and shape.
|
abstract
static
<T extends TType>
T
|
of(Class<T> type, Shape shape, ByteDataBuffer rawData)
Creates a Tensor of any type from the raw data provided by the given buffer.
|
abstract
Shape
|
shape()
Returns the shape of the tensor.
|
From interface
java.lang.AutoCloseable
Public Methods
public
static
abstract
TFloat16
scalarOf
(float value)
Allocates a new tensor for storing a single float value.
Parameters
value |
float to store in the new tensor |
public
static
abstract
TFloat16
tensorOf
(Shape shape)
Allocates a new tensor of the given shape.
Parameters
shape |
shape of the tensor to allocate |
Allocates a new tensor of the given shape, initialized with the provided data.
Parameters
shape |
shape of the tensor to allocate |
data |
buffer of floats to initialize the tensor with |
public
static
abstract
TFloat16
tensorOf
(Shape shape, Consumer<TFloat16> dataInit)
Allocates a new tensor of the given shape and initialize its data.
Parameters
shape |
shape of the tensor to allocate |
dataInit |
tensor data initializer |
public
static
abstract
TFloat16
tensorOf
(NdArray<Float> src)
Allocates a new tensor which is a copy of a given array of floats.
The tensor will have the same shape as the source array and its data will be copied.
Parameters
src |
the source array giving the shape and data to the new tensor |
public
static
abstract
TFloat16
vectorOf
(float... values)
Allocates a new tensor for storing a vector of floats.
Parameters
values |
floats to store in the new tensor |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-11-29 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2021-11-29 UTC."],[],[]]