Annex v0.2.1 Annex.Shape View Source
The Shape module encapsulates helper functions for use in determining the shapes and validity of shapes between Layers and Layers; Data and Data; and Data and Layers.
Link to this section Summary
Functions
Given a valid shape
checks the content of the shape to determine whether
the shape
is a :concrete
kind or an :abstract
kind of shape.
Returns the product of a concrete shape
. Given an abstract shape
product/1
will raise an ArithmeticError. The closest related function to product/1 is
factor/1
. If you need the product of the integers without the :any
in the
shape use factor/2
.
Link to this section Types
abstract()
View Source
abstract() :: [abstract_dimension(), ...]
abstract() :: [abstract_dimension(), ...]
abstract_dimension()
View Source
abstract_dimension() :: concrete_dimension() | shape_any()
abstract_dimension() :: concrete_dimension() | shape_any()
concrete()
View Source
concrete() :: [concrete_dimension(), ...]
concrete() :: [concrete_dimension(), ...]
concrete_dimension()
View Source
concrete_dimension() :: pos_integer()
concrete_dimension() :: pos_integer()
shape_any()
View Source
shape_any() :: :any
shape_any() :: :any
Link to this section Functions
convert_abstract_to_concrete(abstract, concrete) View Source
factor(shape)
View Source
factor(t()) :: pos_integer()
factor(t()) :: pos_integer()
is_factor_of?(num, factor) View Source
is_shape(x) View Source (macro)
is_shape?(shape) View Source
is_shape_value?(n) View Source
kind(shape)
View Source
kind(t()) :: :abstract | :concrete
kind(t()) :: :abstract | :concrete
Given a valid shape
checks the content of the shape to determine whether
the shape
is a :concrete
kind or an :abstract
kind of shape.
A :concrete
shape contains only positive integers and represents a known,
exact shape. For example, the shape [3, 4]
represents a two dimensional
matrix that has 3 rows and 4 columns. Data
always has a :concrete
shape;
the elements of a Data
can be counted.
An :abstract
shape contains both positive integers and/or :any
. An
:abstract
shape represents a partially unknown shape. For example, the
shape [3, :any]
represents a two dimensional shape that has 3 rows and
any positive integer n
number of columns.
Some operations on Data
can express shape requirements in an :abstract
way.
The :abstract
shape idea is particularly useful for describing the
possible valid shapes for casting data for a shaped Layer
. For example,
during feedfoward a Dense
layer requires that input
has the same number
of rows as the Dense layer has columns so that it can perform a matrix dot
operation. For a Dense layer with 2 rows and 3 columns the shape it demands
for casting would be [3, :any]
.
product(shape)
View Source
product(concrete()) :: pos_integer()
product(concrete()) :: pos_integer()
Returns the product of a concrete shape
. Given an abstract shape
product/1
will raise an ArithmeticError. The closest related function to product/1 is
factor/1
. If you need the product of the integers without the :any
in the
shape use factor/2
.
For more info about concrete vs abstract shapes see Shape.kind/1
.