Making Predictions
Making predictions with predictors.
The very first step in making predictions is finding a prediction function to use:
Explore Predictors on Function
Explore public predictors on Function. These predictors can be used by any user on the Function platform.
Making Predictions
Making predictions with Function can be done in as little as two lines of code.
Using Prediction Values
Function supports a fixed set of value types for prediction input and output values:
Floating Point Values
Floating Point Values
Function supports the following floating-point numbers:
Function value type | C/C++ type | Description |
---|---|---|
float16 | float16_t | IEEE 754 16-bit floating point number. |
float32 | float | IEEE 754 32-bit floating point number. |
float64 | double | IEEE 754 64-bit floating point number. |
In languages that don’t support fixed-size floating point scalars, the data type for floating point values
defaults to float32
. Use a tensor constructor to explicitly specify the data type.
Support for half-precision floating point scalars float16
is planned for the future depending on language support.
Function supports floating point vectors (i.e. one-dimensional floating point tensors):
Although Function supports input vectors, predictors will always output either scalars or Tensor
instances—never plain vectors.
Function supports floating point tensors:
Integer Values
Integer Values
Function supports several signed and unsigned integer scalars:
Function value type | C/C++ type | Description |
---|---|---|
int8 | int8_t | Signed 8-bit integer. |
int16 | int16_t | Signed 16-bit integer. |
int32 | int32_t | Signed 32-bit integer. |
int64 | int64_t | Signed 64-bit integer. |
uint8 | uint8_t | Unsigned 8-bit integer. |
uint16 | uint16_t | Unsigned 16-bit integer. |
uint32 | uint32_t | Unsigned 32-bit integer. |
uint64 | uint64_t | Unsigned 64-bit integer. |
When integer scalars are passed to predictors, the data type defaults to int32
. Use
a tensor constructor to explicitly specify the data type.
Function supports integer vectors (i.e. one-dimensional integer tensors) of the aforementioned integer types:
Although Function supports input vectors, predictors will always output either scalars or Tensor
instances—never plain vectors.
Function supports integer tensors:
Unsigned integer tensors are not supported in our Android client because of missing language support in Java.
Boolean Values
Boolean Values
Function supports boolean scalars:
Function supports boolean vectors (i.e. one-dimensional boolean tensors):
Although Function supports input vectors, predictors will always output either scalars or Tensor
instances—never plain vectors.
Function supports boolean tensors:
Function assumes that boolean values are 1 byte.
String Values
String Values
Function supports string values:
List Values
List Values
Function supports lists of values, each with potentially different types:
Input list values must be JSON-serializable.
Dictionary Values
Dictionary Values
Function supports dictionary values:
Input dictionary values must be JSON-serializable.
Image Values
Image Values
Function supports images, represented as raw pixel buffers with 8 bytes per pixel and interleaved by channel. Function supports three pixel buffer formats:
Pixel format | Channels | Description |
---|---|---|
A8 | 1 | Single channel luminance or alpha image. |
RGB888 | 3 | Color image without alpha channel. |
RGBA8888 | 4 | Color image with alpha channel. |
Some client SDKs provide Image
utility types for working with images:
Binary Values
Binary Values
Function supports binary blobs:
Because Function’s security model prohibits file system access, binary input values are always fully read into memory before being passed to the predictor.
To make predictions on large files, consider mapping the file into memory
using mmap
or your environment’s equivalent.