@InternalApi public final class TensorUtils extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_STRING_LEN |
| Modifier and Type | Method and Description |
|---|---|
static TensorData |
convertNestedMapToTensor(java.util.Map<java.lang.String,java.lang.Object> map,
TensorType tensorType)
Convert a nested map into Tensor.
|
static TensorData |
convertNestedMapToTensor(java.util.Map<java.lang.String,java.lang.Object> map,
TensorType tensorType,
TensorBuilderFactory tensorBuilderFactory)
Convert a nested map into Tensor.
|
static java.util.Map<ReadableTuple,java.lang.Float> |
convertTensorToMap(TensorData tensor)
Converts a tensor to a map.
|
static java.util.Map<ReadableTuple,java.lang.Object> |
convertTensorToMapWithGenericValues(TensorData tensor)
Converts a tensor to a map.
|
static LOLTensorData |
convertToLOLTensor(TensorData ut) |
static java.lang.String[] |
convertToStrings(TensorType tensorType,
ReadableTuple readableTuple,
int numCols) |
static java.lang.String |
getDebugString(TensorType type,
TensorData data,
int maxStringLenLimit) |
static long[] |
getShape(TensorType tensorType)
Get shape of the tensor as an array
|
static TensorType |
parseTensorType(java.lang.String syntax)
Deprecated.
|
static TensorData |
populateTensor(Representable[] columnTypes,
java.lang.Object[][] data,
TensorBuilder tensorBuilder)
Creates a Tensor object with the associated columnTypes and data using TensorBuilder
|
static int |
safeRatio(int numerator,
int denominator) |
static <K> java.util.function.Function<ReadableTuple,K> |
wrapKeyGen(TensorType inputTensor,
java.util.function.Function<java.lang.String[],K> keyGen) |
public static final int DEFAULT_MAX_STRING_LEN
public static java.lang.String getDebugString(TensorType type, TensorData data, int maxStringLenLimit)
public static TensorData convertNestedMapToTensor(java.util.Map<java.lang.String,java.lang.Object> map, TensorType tensorType)
TensorType.getDimensionTypes() along with
DimensionType#setDimensionValue(WriteableTuple, int, Object)} method and populates the output tensormap - A nested map to be converted to tensortensorType - TensorType of the output tensorpublic static TensorData convertNestedMapToTensor(java.util.Map<java.lang.String,java.lang.Object> map, TensorType tensorType, TensorBuilderFactory tensorBuilderFactory)
TensorType.getDimensionTypes() (int, String)} method and populates the output tensormap - A nested map to be converted to tensortensorType - TensorType of the output tensortensorBuilderFactory - Factory to generate correct implementation of tensorpublic static java.util.Map<ReadableTuple,java.lang.Float> convertTensorToMap(TensorData tensor)
tensor - input tensor to convert to a mappublic static java.util.Map<ReadableTuple,java.lang.Object> convertTensorToMapWithGenericValues(TensorData tensor)
tensor - input tensor to convert to a mappublic static LOLTensorData convertToLOLTensor(TensorData ut)
public static java.lang.String[] convertToStrings(TensorType tensorType, ReadableTuple readableTuple, int numCols)
public static <K> java.util.function.Function<ReadableTuple,K> wrapKeyGen(TensorType inputTensor, java.util.function.Function<java.lang.String[],K> keyGen)
public static long[] getShape(TensorType tensorType)
tensorType - Type for which shape needs to be computedpublic static TensorData populateTensor(Representable[] columnTypes, java.lang.Object[][] data, TensorBuilder tensorBuilder)
columnTypes - columnTypes of the tensordata - data within the tensor
data.length corresponds to the number of rows the tensor has
data[i].length corresponds to the number of columns in a tensor row.
Each element in data[i] corresponds to the dimension/value of the tensor at row itensorBuilder - tensorbuilder representing the data@Deprecated public static TensorType parseTensorType(java.lang.String syntax)
TensorTypes.parseTensorType(java.lang.String)public static int safeRatio(int numerator,
int denominator)