nvidia.dali.experimental.dynamic.lookup_table#
- nvidia.dali.experimental.dynamic.lookup_table(input, /, *, batch_size=None, device=None, default_value=None, dtype=None, keys=None, output_dtype=None, values=None)#
Maps the input to output by using a lookup table that is specified by
keysandvalues, and adefault_valuefor unspecified keys.For example when
keysandvaluesare used to define the lookup table in the following way:keys[] = {0, 2, 3, 4, 5, 3} values[] = {0.2, 0.4, 0.5, 0.6, 0.7, 0.10} default_value = 0.99 0 <= i < max(keys) lut[i] = values[keys.index[i]] if i in keys lut[i] = default_value otherwise
the operator creates the following table:
lut[] = {0.2, 0.99, 0.4, 0.10, 0.6, 0.7} // only last occurrence of a key is considered
and produces the output according to this formula:
Output[i] = lut[Input[i]] if 0 <= Input[i] <= len(lut) Output[i] = default_value otherwise
Here is a practical example, considering the table defined above:
Input[] = {1, 4, 1, 0, 100, 2, 3, 4} Output[] = {0.99, 0.6, 0.99, 0.2, 0.99, 0.4, 0.10, 0.6}
Note
Only integer types can be used as inputs for this operator.
This operator allows sequence inputs and supports volumetric data.
- Supported backends
‘cpu’
‘gpu’
- Parameters:
input¶ (Tensor/Batch) – Input to the operator.
- Keyword Arguments:
default_value¶ (float, optional, default = 0.0) – Default output value for keys that are not present in the table.
dtype¶ (
nvidia.dali.types.DALIDataType, optional, default = DALIDataType.FLOAT) – Output data type.keys¶ (int or list of int, optional, default = []) –
A list of input values (keys) in the lookup table.
The length of
keysandvaluesargument must match. The values inkeysshould be in the [0, 65535 ] range.output_dtype¶ (
nvidia.dali.types.DALIDataType) –Warning
The argument
output_dtypeis a deprecated alias fordtype. Usedtypeinstead.values¶ (float or list of float, optional, default = []) –