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 |
tensorOf(Shape shape, FloatDataBuffer data)
Allocates a new tensor of the given shape, initialized with the provided data.
|
abstract static TFloat16 | |
abstract static TFloat16 | |
abstract static TFloat16 |
vectorOf(float... values)
Allocates a new tensor for storing a vector of floats.
|
Inherited Methods
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 |
---|
Returns
- 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 |
---|
Returns
- the new tensor
public static abstract TFloat16 tensorOf (Shape shape, FloatDataBuffer data)
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 |
Returns
- the new tensor
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 |
Returns
- the new tensor
Throws
TensorFlowException | if the tensor cannot be allocated or initialized |
---|
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 |
---|
Returns
- 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 |
---|
Returns
- the new tensor