Annex v0.2.1 Annex.Data behaviour View Source
Annex.Data defines the callbacks and helpers for data structures used by Annex.
An implementer of the Annex.Layer behaviour must return an Annex.Data
implementer from the c:data_type/0
callback.
Link to this section Summary
Functions
Annex.Data.cast/4 calls cast/3 for an Annex.Data behaviour implementing module.
Given a type
, data
, and a target_shape
converts the data to the type
and target_shape
Given a type (Data implementing module) and some data
returns true or false if the
data is of the correct type.
Given an Annex.Data type
and the data
returns the shape of the data.
Flattens an Annex.Data into a list of floats via Enum.into/2.
Flattens an Annex.Data into a list of floats via the type's callback.
Link to this section Types
args()
View Source
args() :: [any()]
args() :: [any()]
data() View Source
flat_data()
View Source
flat_data() :: [float(), ...]
flat_data() :: [float(), ...]
op()
View Source
op() :: any()
op() :: any()
type()
View Source
type() :: module()
type() :: module()
A module that implements the Annex.Data Behaviour.
Link to this section Functions
apply_op(data, name, args) View Source
apply_op(type, data, name, args) View Source
cast(data, shape)
View Source
cast(Annex.Data.data(), Annex.Shape.t()) :: Annex.Data.data()
cast(Annex.Data.data(), Annex.Shape.t()) :: Annex.Data.data()
cast(type, data, shape) View Source
Annex.Data.cast/4 calls cast/3 for an Annex.Data behaviour implementing module.
Valid shapes are a non-empty tuple of positive integers or any the atom :any.
e.g. {2, 3}
or {3, :any}
convert(type, data, target_shape) View Source
Given a type
, data
, and a target_shape
converts the data to the type
and target_shape
If the data
matches the type
and the data_shape
matches the target_shape
the
data is returned unaltered.
If either the type
or target_shape
do not match the data
the data is casted using
Data.cast/3
.
error(outputs, labels)
View Source
error(Annex.Data.data(), Annex.Data.data()) :: Annex.Data.flat_data()
error(Annex.Data.data(), Annex.Data.data()) :: Annex.Data.flat_data()
flat_data_to_tensor(flat_data, shape) View Source
infer_type(item) View Source
is_flat_data(data) View Source (macro)
is_type?(type, data) View Source
Given a type (Data implementing module) and some data
returns true or false if the
data is of the correct type.
Calls is_type?/1
of the type
.
shape(data)
View Source
shape(data()) :: Annex.Shape.t()
shape(data()) :: Annex.Shape.t()
shape(type, data)
View Source
shape(type(), data()) :: Annex.Shape.t()
shape(type(), data()) :: Annex.Shape.t()
Given an Annex.Data type
and the data
returns the shape of the data.
The shape of data is used to cast between the expected shapes from one Annex.Layer to the next or from one Annex.Sequence to the next.
to_flat_list(data)
View Source
to_flat_list(Annex.Data.data()) :: Annex.Data.flat_data()
to_flat_list(Annex.Data.data()) :: Annex.Data.flat_data()
Flattens an Annex.Data into a list of floats via Enum.into/2.
to_flat_list(type, data)
View Source
to_flat_list(type(), data()) :: Annex.Data.flat_data()
to_flat_list(type(), data()) :: Annex.Data.flat_data()
Flattens an Annex.Data into a list of floats via the type's callback.
Link to this section Callbacks
apply_op(data, op, args) View Source
cast(data, arg2)
View Source
cast(data(), Annex.Shape.t()) :: data()
cast(data(), Annex.Shape.t()) :: data()
is_type?(any) View Source
shape(data)
View Source
shape(data()) :: Annex.Shape.t()
shape(data()) :: Annex.Shape.t()