ceras
yet another deep learning engine
Classes | Namespaces | Functions | Variables
operation.hpp File Reference
#include "./includes.hpp"
#include "./place_holder.hpp"
#include "./variable.hpp"
#include "./constant.hpp"
#include "./value.hpp"
#include "./utils/range.hpp"
#include "./utils/debug.hpp"
#include "./config.hpp"
#include "./utils/context_cast.hpp"
#include "./utils/for_each.hpp"
#include "./utils/id.hpp"
#include "./utils/enable_shared.hpp"

Go to the source code of this file.

Classes

struct  ceras::unary_operator< Operator, Forward_Action, Backward_Action >
 
struct  ceras::binary_operator< Lhs_Operator, Rhs_Operator, Forward_Action, Backward_Action >
 
struct  ceras::is_unary_operator< T >
 
struct  ceras::is_unary_operator< unary_operator< Operator, Forward_Action, Backward_Action > >
 
struct  ceras::is_binary_operator< T >
 
struct  ceras::is_binary_operator< binary_operator< Lhs_Operator, Rhs_Operator, Forward_Action, Backward_Action > >
 

Namespaces

 ceras
 

Functions

template<Expression Ex>
std::string ceras::computation_graph (Ex const &ex) noexcept
 
template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto ceras::plus (Lhs_Expression const &lhs_ex, Rhs_Expression const &rhs_ex) noexcept
 
template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto ceras::operator+ (Lhs_Expression const &lhs_ex, Rhs_Expression const &rhs_ex) noexcept
 
template<Expression Ex>
constexpr auto ceras::operator+ (Ex const &ex) noexcept
 
template<Expression Lhs_Expression, Expression Rhs_Expression>
auto ceras::operator* (Lhs_Expression const &lhs_ex, Rhs_Expression const &rhs_ex) noexcept
 
template<Expression Ex>
constexpr auto ceras::negative (Ex const &ex) noexcept
 
template<Expression Ex>
constexpr auto ceras::operator- (Ex const &ex) noexcept
 
template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto ceras::elementwise_product (Lhs_Expression const &lhs_ex, Rhs_Expression const &rhs_ex) noexcept
 
template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto ceras::elementwise_multiply (Lhs_Expression const &lhs_ex, Rhs_Expression const &rhs_ex) noexcept
 
template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto ceras::hadamard_product (Lhs_Expression const &lhs_ex, Rhs_Expression const &rhs_ex) noexcept
 
template<Expression Ex>
constexpr auto ceras::sum_reduce (Ex const &ex) noexcept
 
template<Expression Ex>
constexpr auto ceras::reduce_sum (Ex const &ex) noexcept
 
template<Expression Ex>
constexpr auto ceras::mean_reduce (Ex const &ex) noexcept
 Computes the mean of elements across all dimensions of an expression. More...
 
template<Expression Ex>
constexpr auto ceras::reduce_mean (Ex const &ex) noexcept
 An alias name of mean_reduce. More...
 
template<Expression Ex>
constexpr auto ceras::mean (Ex const &ex) noexcept
 An alias name of mean_reduce. More...
 
template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto ceras::minus (Lhs_Expression const &lhs_ex, Rhs_Expression const &rhs_ex) noexcept
 
template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto ceras::operator- (Lhs_Expression const &lhs_ex, Rhs_Expression const &rhs_ex) noexcept
 
template<Expression Ex>
constexpr auto ceras::square (Ex const &ex) noexcept
 
template<Expression Ex, Expression Ey>
*endcode **constexpr auto hypot (Ex const &ex, Ey const &ey) noexcept
 
template<typename Float >
requires std::floating_point< Float > constexpr auto clip (Float lower, Float upper=std::numeric_limits< Float >::max()) noexcept
 
auto reshape (std::vector< unsigned long > const &new_shape, bool include_batch_flag=true) noexcept
 
template<Expression Ex>
constexpr auto flatten (Ex const &ex) noexcept
 
template<Expression Ex>
constexpr auto identity (Ex const &ex) noexcept
 
template<Expression Ex>
auto transpose (Ex const &ex) noexcept
 
auto img2col (unsigned long const row_kernel, unsigned long col_kernel=-1, unsigned long const row_padding=0, unsigned long col_padding=0, unsigned long const row_stride=1, unsigned long const col_stride=1, unsigned long const row_dilation=1, unsigned long const col_dilation=1) noexcept
 
auto conv2d (unsigned long row_input, unsigned long col_input, unsigned long const row_stride=1, unsigned long const col_stride=1, unsigned long const row_dilation=1, unsigned long const col_dilation=1, std::string const &padding="valid") noexcept
 
template<typename T >
requires std::floating_point< T > auto drop_out (T const factor) noexcept
 
auto max_pooling_2d (unsigned long stride) noexcept
 
auto average_pooling_2d (unsigned long stride) noexcept
 
auto up_sampling_2d (unsigned long stride) noexcept
 
template<typename T = double>
requires std::floating_point< T > auto normalization_batch (T const momentum=0.98) noexcept
 
template<typename T >
requires std::floating_point< T > auto batch_normalization (T const momentum=0.98) noexcept
 
template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto concatenate (Lhs_Expression const &lhs_ex, Rhs_Expression const &rhs_ex) noexcept
 
auto concatenate (unsigned long axe=-1)
 
template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto concat (Lhs_Expression const &lhs_ex, Rhs_Expression const &rhs_ex) noexcept
 
auto concat (unsigned long axe=-1)
 
template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto maximum (Lhs_Expression const &lhs_ex, Rhs_Expression const &rhs_ex) noexcept
 
template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto minimum (Lhs_Expression const &lhs_ex, Rhs_Expression const &rhs_ex) noexcept
 
template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto atan2 (Lhs_Expression const &lhs_ex, Rhs_Expression const &rhs_ex) noexcept
 Computes the arc tangent of y/x using the signs of arguments to determine the correct quadrant. More...
 
template<typename T = float>
requires std::floating_point< T > auto random_normal_like (T mean=0.0, T stddev=1.0) noexcept
 
template<Expression Ex>
auto ones_like (Ex const &ex) noexcept
 
template<Expression Ex>
auto zeros_like (Ex const &ex) noexcept
 
template<Expression Lhs_Expression, Expression Rhs_Expression, std::floating_point FP>
constexpr auto equal (Lhs_Expression const &lhs_ex, Rhs_Expression const &rhs_ex, FP threshold=0.5) noexcept
 
template<Expression Ex>
constexpr auto sign (Ex const &ex) noexcept
 
auto zero_padding_2d (std::vector< unsigned long > const &padding) noexcept
 Zero-padding layer for 2D input. The input should have 4-dimensions: (batch_size, row, col, channel). The output has 4-dimensions: (batch_size, new_row, new_col, channel). More...
 
auto repeat (unsigned long repeats, unsigned long axis=-1) noexcept
 Repeats elements along an axis. More...
 
auto reduce_min (unsigned long axis=-1) noexcept
 Reduce minimal elements along an axis. More...
 
auto reduce_max (unsigned long axis=-1) noexcept
 Reduce maximum elements along an axis. More...
 
auto reduce_sum (unsigned long axis) noexcept
 Reduce sum elements along an axis. More...
 
template<Expression Ex>
constexpr auto abs (Ex const &ex) noexcept
 Computes Abs of the given expression. More...
 
template<Expression Ex>
constexpr auto acos (Ex const &ex) noexcept
 Computes Acos of the given expression. More...
 
template<Expression Ex>
constexpr auto acosh (Ex const &ex) noexcept
 Computes Acosh of the given expression. More...
 
template<Expression Ex>
constexpr auto asin (Ex const &ex) noexcept
 Computes Asin of the given expression. More...
 
template<Expression Ex>
constexpr auto asinh (Ex const &ex) noexcept
 Computes Asinh of the given expression. More...
 
template<Expression Ex>
constexpr auto atan (Ex const &ex) noexcept
 Computes Atan of the given expression. More...
 
template<Expression Ex>
constexpr auto atanh (Ex const &ex) noexcept
 Computes Atanh of the given expression. More...
 
template<Expression Ex>
constexpr auto cbrt (Ex const &ex) noexcept
 Computes Cbert of the given expression. More...
 
template<Expression Ex>
constexpr auto ceil (Ex const &ex) noexcept
 Computes Ceil of the given expression. More...
 
template<Expression Ex>
constexpr auto cos (Ex const &ex) noexcept
 Computes Cos of the given expression. More...
 
template<Expression Ex>
constexpr auto cosh (Ex const &ex) noexcept
 Computes Cosh of the given expression. More...
 
template<Expression Ex>
constexpr auto erf (Ex const &ex) noexcept
 Computes Erf of the given expression. More...
 
template<Expression Ex>
constexpr auto erfc (Ex const &ex) noexcept
 Computes Erfc of the given expression. More...
 
template<Expression Ex>
constexpr auto exp (Ex const &ex) noexcept
 Computes Exp of the given expression. More...
 
template<Expression Ex>
constexpr auto exp2 (Ex const &ex) noexcept
 Computes Exp2 of the given expression. More...
 
template<Expression Ex>
constexpr auto expm1 (Ex const &ex) noexcept
 Computes Expm1 of the given expression. More...
 
template<Expression Ex>
constexpr auto fabs (Ex const &ex) noexcept
 Computes Fabs of the given expression. More...
 
template<Expression Ex>
constexpr auto floor (Ex const &ex) noexcept
 Computes Floor of the given expression. More...
 
template<Expression Ex>
constexpr auto llrint (Ex const &ex) noexcept
 Computes Llrint of the given expression. More...
 
template<Expression Ex>
constexpr auto llround (Ex const &ex) noexcept
 Computes Llround of the given expression. More...
 
template<Expression Ex>
constexpr auto log (Ex const &ex) noexcept
 Computes Log of the given expression. More...
 
template<Expression Ex>
constexpr auto log10 (Ex const &ex) noexcept
 Computes Log10 of the given expression. More...
 
template<Expression Ex>
constexpr auto log1p (Ex const &ex) noexcept
 Computes Log1p of the given expression. More...
 
template<Expression Ex>
constexpr auto log2 (Ex const &ex) noexcept
 Computes Log2 of the given expression. More...
 
template<Expression Ex>
constexpr auto lrint (Ex const &ex) noexcept
 Computes Lrint of the given expression. More...
 
template<Expression Ex>
constexpr auto lround (Ex const &ex) noexcept
 Computes Lround of the given expression. More...
 
template<Expression Ex>
constexpr auto nearbyint (Ex const &ex) noexcept
 Computes Nearbyint of the given expression. More...
 
template<Expression Ex>
constexpr auto rint (Ex const &ex) noexcept
 Computes Rint of the given expression. More...
 
template<Expression Ex>
constexpr auto round (Ex const &ex) noexcept
 Computes Round of the given expression. More...
 
template<Expression Ex>
constexpr auto sin (Ex const &ex) noexcept
 Computes Sin of the given expression. More...
 
template<Expression Ex>
constexpr auto sinh (Ex const &ex) noexcept
 Computes Sinh of the given expression. More...
 
template<Expression Ex>
constexpr auto sqrt (Ex const &ex) noexcept
 Computes Sqrt of the given expression. More...
 
template<Expression Ex>
constexpr auto tan (Ex const &ex) noexcept
 Computes Tan of the given expression. More...
 
template<Expression Ex>
constexpr auto tanh (Ex const &ex) noexcept
 Computes Tanh of the given expression. More...
 
template<Expression Ex>
constexpr auto trunc (Ex const &ex) noexcept
 Computes Trunc of the given expression. More...
 

Variables

static constexpr auto ceras::make_unary_operator
 
static constexpr auto ceras::make_binary_operator
 
template<class T >
constexpr bool ceras::is_unary_operator_v = is_unary_operator<T>::value
 
template<typename T >
concept ceras::Unary_Operator = is_unary_operator_v<T>
 A type that represents an unary operator. More...
 
template<class T >
constexpr bool ceras::is_binary_operator_v = is_binary_operator<T>::value
 
template<typename T >
concept ceras::Binary_Operator = is_binary_operator_v<T>
 A type that represents a binary operator. More...
 
template<typename T >
concept ceras::Operator = Unary_Operator<T> || Binary_Operator<T>
 A type that represents an unary or a binary operator. More...
 
template<typename T >
concept ceras::Expression = Operator<T> || Variable<T> || Place_Holder<T> || Constant<T> || Value<T>
 A type that represents a unary operator, a binary operator, a variable, a place_holder, a constant or a value. More...
 
*auto y = variable<tensor<float>>{ }
 
*auto sqr = hypot( x, y )
 

Function Documentation

◆ abs()

template<Expression Ex>
constexpr auto abs ( Ex const &  ex)
constexprnoexcept

Computes Abs of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = abs( a );
constexpr auto abs(Ex const &ex) noexcept
Computes Abs of the given expression.
Definition: operation.hpp:2447

◆ acos()

template<Expression Ex>
constexpr auto acos ( Ex const &  ex)
constexprnoexcept

Computes Acos of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = acos( a );
constexpr auto acos(Ex const &ex) noexcept
Computes Acos of the given expression.
Definition: operation.hpp:2484

◆ acosh()

template<Expression Ex>
constexpr auto acosh ( Ex const &  ex)
constexprnoexcept

Computes Acosh of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = acosh( a );
constexpr auto acosh(Ex const &ex) noexcept
Computes Acosh of the given expression.
Definition: operation.hpp:2521

◆ asin()

template<Expression Ex>
constexpr auto asin ( Ex const &  ex)
constexprnoexcept

Computes Asin of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = asin( a );
constexpr auto asin(Ex const &ex) noexcept
Computes Asin of the given expression.
Definition: operation.hpp:2558

◆ asinh()

template<Expression Ex>
constexpr auto asinh ( Ex const &  ex)
constexprnoexcept

Computes Asinh of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = asinh( a );
constexpr auto asinh(Ex const &ex) noexcept
Computes Asinh of the given expression.
Definition: operation.hpp:2595

◆ atan()

template<Expression Ex>
constexpr auto atan ( Ex const &  ex)
constexprnoexcept

Computes Atan of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = atan( a );
constexpr auto atan(Ex const &ex) noexcept
Computes Atan of the given expression.
Definition: operation.hpp:2632

◆ atan2()

template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto atan2 ( Lhs_Expression const &  lhs_ex,
Rhs_Expression const &  rhs_ex 
)
constexprnoexcept

Computes the arc tangent of y/x using the signs of arguments to determine the correct quadrant.

◆ atanh()

template<Expression Ex>
constexpr auto atanh ( Ex const &  ex)
constexprnoexcept

Computes Atanh of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = atanh( a );
constexpr auto atanh(Ex const &ex) noexcept
Computes Atanh of the given expression.
Definition: operation.hpp:2669

◆ average_pooling_2d()

auto average_pooling_2d ( unsigned long  stride)
inlinenoexcept

◆ batch_normalization()

template<typename T >
requires std::floating_point<T> auto batch_normalization ( T const  momentum = 0.98)
inlinenoexcept

◆ cbrt()

template<Expression Ex>
constexpr auto cbrt ( Ex const &  ex)
constexprnoexcept

Computes Cbert of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = cbrt( a );
constexpr auto cbrt(Ex const &ex) noexcept
Computes Cbert of the given expression.
Definition: operation.hpp:2706

◆ ceil()

template<Expression Ex>
constexpr auto ceil ( Ex const &  ex)
constexprnoexcept

Computes Ceil of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = ceil( a );
constexpr auto ceil(Ex const &ex) noexcept
Computes Ceil of the given expression.
Definition: operation.hpp:2743

◆ clip()

template<typename Float >
requires std::floating_point<Float> constexpr auto clip ( Float  lower,
Float  upper = std::numeric_limits<Float>::max() 
)
constexprnoexcept

◆ concat() [1/2]

template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto concat ( Lhs_Expression const &  lhs_ex,
Rhs_Expression const &  rhs_ex 
)
constexprnoexcept

◆ concat() [2/2]

auto concat ( unsigned long  axe = -1)
inline

◆ concatenate() [1/2]

template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto concatenate ( Lhs_Expression const &  lhs_ex,
Rhs_Expression const &  rhs_ex 
)
constexprnoexcept

◆ concatenate() [2/2]

auto concatenate ( unsigned long  axe = -1)
inline

◆ conv2d()

auto conv2d ( unsigned long  row_input,
unsigned long  col_input,
unsigned long const  row_stride = 1,
unsigned long const  col_stride = 1,
unsigned long const  row_dilation = 1,
unsigned long const  col_dilation = 1,
std::string const &  padding = "valid" 
)
inlinenoexcept

◆ cos()

template<Expression Ex>
constexpr auto cos ( Ex const &  ex)
constexprnoexcept

Computes Cos of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = cos( a );
constexpr auto cos(Ex const &ex) noexcept
Computes Cos of the given expression.
Definition: operation.hpp:2777

◆ cosh()

template<Expression Ex>
constexpr auto cosh ( Ex const &  ex)
constexprnoexcept

Computes Cosh of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = cosh( a );
constexpr auto cosh(Ex const &ex) noexcept
Computes Cosh of the given expression.
Definition: operation.hpp:2814

◆ drop_out()

template<typename T >
requires std::floating_point<T> auto drop_out ( T const  factor)
inlinenoexcept

◆ equal()

template<Expression Lhs_Expression, Expression Rhs_Expression, std::floating_point FP>
constexpr auto equal ( Lhs_Expression const &  lhs_ex,
Rhs_Expression const &  rhs_ex,
FP  threshold = 0.5 
)
constexprnoexcept

Returns the truth value of (lhs == rhs) element-wise. [+1 for true, 0 for false]

Parameters
lhs_exThe first operator.
rhs_exThe second operator.
Returns
An instance of a binary operator that evaluate the element-wise equality of two input operators.

Example code:

auto l = variable<tensor<float>>{ /*...*/ };
auto r = place_holder<tensor<float>>{};
auto eq = equal(l, r);
constexpr auto equal(Lhs_Expression const &lhs_ex, Rhs_Expression const &rhs_ex, FP threshold=0.5) noexcept
Definition: operation.hpp:1789

◆ erf()

template<Expression Ex>
constexpr auto erf ( Ex const &  ex)
constexprnoexcept

Computes Erf of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = erf( a );
constexpr auto erf(Ex const &ex) noexcept
Computes Erf of the given expression.
Definition: operation.hpp:2851

◆ erfc()

template<Expression Ex>
constexpr auto erfc ( Ex const &  ex)
constexprnoexcept

Computes Erfc of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = erfc( a );
constexpr auto erfc(Ex const &ex) noexcept
Computes Erfc of the given expression.
Definition: operation.hpp:2888

◆ exp()

template<Expression Ex>
constexpr auto exp ( Ex const &  ex)
constexprnoexcept

Computes Exp of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = exp( a );
constexpr auto exp(Ex const &ex) noexcept
Computes Exp of the given expression.
Definition: operation.hpp:2926

◆ exp2()

template<Expression Ex>
constexpr auto exp2 ( Ex const &  ex)
constexprnoexcept

Computes Exp2 of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = exp2( a );
constexpr auto exp2(Ex const &ex) noexcept
Computes Exp2 of the given expression.
Definition: operation.hpp:2963

◆ expm1()

template<Expression Ex>
constexpr auto expm1 ( Ex const &  ex)
constexprnoexcept

Computes Expm1 of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = expm1( a );
constexpr auto expm1(Ex const &ex) noexcept
Computes Expm1 of the given expression.
Definition: operation.hpp:3000

◆ fabs()

template<Expression Ex>
constexpr auto fabs ( Ex const &  ex)
constexprnoexcept

Computes Fabs of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = fabs( a );
constexpr auto fabs(Ex const &ex) noexcept
Computes Fabs of the given expression.
Definition: operation.hpp:3037

◆ flatten()

template<Expression Ex>
constexpr auto flatten ( Ex const &  ex)
constexprnoexcept

◆ floor()

template<Expression Ex>
constexpr auto floor ( Ex const &  ex)
constexprnoexcept

Computes Floor of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = floor( a );
constexpr auto floor(Ex const &ex) noexcept
Computes Floor of the given expression.
Definition: operation.hpp:3057

◆ hypot()

template<Expression Ex, Expression Ey>
* endcode* * constexpr auto hypot ( Ex const &  ex,
Ey const &  ey 
)
constexprnoexcept

◆ identity()

template<Expression Ex>
constexpr auto identity ( Ex const &  ex)
constexprnoexcept

◆ img2col()

auto img2col ( unsigned long const  row_kernel,
unsigned long  col_kernel = -1,
unsigned long const  row_padding = 0,
unsigned long  col_padding = 0,
unsigned long const  row_stride = 1,
unsigned long const  col_stride = 1,
unsigned long const  row_dilation = 1,
unsigned long const  col_dilation = 1 
)
inlinenoexcept

◆ llrint()

template<Expression Ex>
constexpr auto llrint ( Ex const &  ex)
constexprnoexcept

Computes Llrint of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = llrint( a );
constexpr auto llrint(Ex const &ex) noexcept
Computes Llrint of the given expression.
Definition: operation.hpp:3165

◆ llround()

template<Expression Ex>
constexpr auto llround ( Ex const &  ex)
constexprnoexcept

Computes Llround of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = llround( a );
constexpr auto llround(Ex const &ex) noexcept
Computes Llround of the given expression.
Definition: operation.hpp:3198

◆ log()

template<Expression Ex>
constexpr auto log ( Ex const &  ex)
constexprnoexcept

Computes Log of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = log( a );
constexpr auto log(Ex const &ex) noexcept
Computes Log of the given expression.
Definition: operation.hpp:3231

◆ log10()

template<Expression Ex>
constexpr auto log10 ( Ex const &  ex)
constexprnoexcept

Computes Log10 of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = log10( a );
constexpr auto log10(Ex const &ex) noexcept
Computes Log10 of the given expression.
Definition: operation.hpp:3268

◆ log1p()

template<Expression Ex>
constexpr auto log1p ( Ex const &  ex)
constexprnoexcept

Computes Log1p of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = log1p( a );
constexpr auto log1p(Ex const &ex) noexcept
Computes Log1p of the given expression.
Definition: operation.hpp:3305

◆ log2()

template<Expression Ex>
constexpr auto log2 ( Ex const &  ex)
constexprnoexcept

Computes Log2 of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = log2( a );
constexpr auto log2(Ex const &ex) noexcept
Computes Log2 of the given expression.
Definition: operation.hpp:3342

◆ lrint()

template<Expression Ex>
constexpr auto lrint ( Ex const &  ex)
constexprnoexcept

Computes Lrint of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = lrint( a );
constexpr auto lrint(Ex const &ex) noexcept
Computes Lrint of the given expression.
Definition: operation.hpp:3417

◆ lround()

template<Expression Ex>
constexpr auto lround ( Ex const &  ex)
constexprnoexcept

Computes Lround of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = lround( a );
constexpr auto lround(Ex const &ex) noexcept
Computes Lround of the given expression.
Definition: operation.hpp:3451

◆ max_pooling_2d()

auto max_pooling_2d ( unsigned long  stride)
inlinenoexcept

◆ maximum()

template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto maximum ( Lhs_Expression const &  lhs_ex,
Rhs_Expression const &  rhs_ex 
)
constexprnoexcept

◆ minimum()

template<Expression Lhs_Expression, Expression Rhs_Expression>
constexpr auto minimum ( Lhs_Expression const &  lhs_ex,
Rhs_Expression const &  rhs_ex 
)
constexprnoexcept

◆ nearbyint()

template<Expression Ex>
constexpr auto nearbyint ( Ex const &  ex)
constexprnoexcept

Computes Nearbyint of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = nearbyint( a );
constexpr auto nearbyint(Ex const &ex) noexcept
Computes Nearbyint of the given expression.
Definition: operation.hpp:3484

◆ normalization_batch()

template<typename T = double>
requires std::floating_point<T> auto normalization_batch ( T const  momentum = 0.98)
inlinenoexcept

◆ ones_like()

template<Expression Ex>
auto ones_like ( Ex const &  ex)
noexcept

ones_like produces a tensor of the same shape as the input expression, but with every element to be 1.

Returns
An unary operator that takes an unary operator, and producing an output tensor Example Code:
auto va = variable{ ones<float>({3, 3, 3}) };
auto v_rand = ones_like( va ); // this expression will produces a tensor of shape (3, 3, 3), with every element to be 1.
auto ones_like(Ex const &ex) noexcept
Definition: operation.hpp:1744

◆ random_normal_like()

template<typename T = float>
requires std::floating_point<T> auto random_normal_like ( mean = 0.0,
stddev = 1.0 
)
inlinenoexcept

random_normal_like produces random tensor from a normal distribution

Parameters
meanMean of the normal distribution, a scalar.
stddevStandard deviation of the normal distribution, a scalar.
Returns
An unary operator that takes an unary operator, and producing output tensor from a normal distribution. The shape of the output tensor has the same shape corresponding to the input unary operator.

Example Code

auto va = variable{ ones<float>({3, 3, 3}) };
auto v_rand = random_normal_like( 1.0, 4.0 )( va ); // this expression will produces a tensor of shape (3, 3, 3) from a normal distribution with parameters (1.0, 4.0)
requires std::floating_point< T > auto random_normal_like(T mean=0.0, T stddev=1.0) noexcept
Definition: operation.hpp:1714

◆ reduce_max()

auto reduce_max ( unsigned long  axis = -1)
inlinenoexcept

Reduce maximum elements along an axis.

Parameters
axisThe axis along which to reduce maximum values. Defaults to the last axis.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = reduce_max( 0 )( a ); // <- output shape is ( 3, 5 )
auto b = reduce_max( 1 )( a ); // <- output shape is ( 2, 5 )
auto b = reduce_max( 2 )( a ); // <- output shape is ( 2, 3 )
auto b = reduce_max( )( a ); // <- output shape is ( 2, 3 )
auto reduce_max(unsigned long axis=-1) noexcept
Reduce maximum elements along an axis.
Definition: operation.hpp:2307

◆ reduce_min()

auto reduce_min ( unsigned long  axis = -1)
inlinenoexcept

Reduce minimal elements along an axis.

Parameters
axisThe axis along which to reduce minimal values. Defaults to the last axis.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = reduce_min( 0 )( a ); // <- output shape is ( 3, 5 )
auto b = reduce_min( 1 )( a ); // <- output shape is ( 2, 5 )
auto b = reduce_min( 2 )( a ); // <- output shape is ( 2, 3 )
auto b = reduce_min( )( a ); // <- output shape is ( 2, 3 )
auto reduce_min(unsigned long axis=-1) noexcept
Reduce minimal elements along an axis.
Definition: operation.hpp:2181

◆ reduce_sum()

auto reduce_sum ( unsigned long  axis)
inlinenoexcept

Reduce sum elements along an axis.

Parameters
axisThe axis along which to reduce sum.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = reduce_sum( 0 )( a ); // <- output shape is ( 3, 5 )
auto b = reduce_sum( 1 )( a ); // <- output shape is ( 2, 5 )
auto b = reduce_sum( 2 )( a ); // <- output shape is ( 2, 3 )
auto b = reduce_sum( -1 )( a ); // <- output shape is ( 2, 3 )
auto reduce_sum(unsigned long axis) noexcept
Reduce sum elements along an axis.
Definition: operation.hpp:2415

◆ repeat()

auto repeat ( unsigned long  repeats,
unsigned long  axis = -1 
)
inlinenoexcept

Repeats elements along an axis.

Parameters
repeatsThe number of repetitions for each element.
axisThe axis along which to repeat values. Defaults to the last axis.

Example code:

auto a = variable{ random<float>( {2, 3, 5} };
auto b0 = repeat( 2, 0 )( a ); // <- output shape is ( 4, 3, 5 )
auto b1 = repeat( 2, 1 )( a ); // <- output shape is ( 2, 6, 5 )
auto b2 = repeat( 2, 2 )( a ); // <- output shape is ( 2, 3, 10 )
auto bx = repeat( 2 )( a ); // <- output shape is ( 2, 3, 10 )
auto repeat(unsigned long repeats, unsigned long axis=-1) noexcept
Repeats elements along an axis.
Definition: operation.hpp:2055

◆ reshape()

auto reshape ( std::vector< unsigned long > const &  new_shape,
bool  include_batch_flag = true 
)
inlinenoexcept

◆ rint()

template<Expression Ex>
constexpr auto rint ( Ex const &  ex)
constexprnoexcept

Computes Rint of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = rint( a );
constexpr auto rint(Ex const &ex) noexcept
Computes Rint of the given expression.
Definition: operation.hpp:3517

◆ round()

template<Expression Ex>
constexpr auto round ( Ex const &  ex)
constexprnoexcept

Computes Round of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = round( a );
constexpr auto round(Ex const &ex) noexcept
Computes Round of the given expression.
Definition: operation.hpp:3550

◆ sign()

template<Expression Ex>
constexpr auto sign ( Ex const &  ex)
constexprnoexcept

Returns the sign. [1 for positive, 0 for 0 and -1 for negative]

Parameters
exThe input operator.
Returns
An instance of a unary_operator that evaluate the sign of the input operator.

Example code:

auto e = variable<tensor<float>>{ /*...*/ };
auto si = sign(e);
constexpr auto sign(Ex const &ex) noexcept
Definition: operation.hpp:1829

◆ sin()

template<Expression Ex>
constexpr auto sin ( Ex const &  ex)
constexprnoexcept

Computes Sin of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = sin( a );
constexpr auto sin(Ex const &ex) noexcept
Computes Sin of the given expression.
Definition: operation.hpp:3583

◆ sinh()

template<Expression Ex>
constexpr auto sinh ( Ex const &  ex)
constexprnoexcept

Computes Sinh of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = sinh( a );
constexpr auto sinh(Ex const &ex) noexcept
Computes Sinh of the given expression.
Definition: operation.hpp:3620

◆ sqrt()

template<Expression Ex>
constexpr auto sqrt ( Ex const &  ex)
constexprnoexcept

Computes Sqrt of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = sqrt( a );
constexpr auto sqrt(Ex const &ex) noexcept
Computes Sqrt of the given expression.
Definition: operation.hpp:3657

◆ tan()

template<Expression Ex>
constexpr auto tan ( Ex const &  ex)
constexprnoexcept

Computes Tan of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = tan( a );
constexpr auto tan(Ex const &ex) noexcept
Computes Tan of the given expression.
Definition: operation.hpp:3694

◆ tanh()

template<Expression Ex>
constexpr auto tanh ( Ex const &  ex)
constexprnoexcept

Computes Tanh of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = tanh( a );
constexpr auto tanh(Ex const &ex) noexcept
Computes Tanh of the given expression.
Definition: operation.hpp:3731

◆ transpose()

template<Expression Ex>
auto transpose ( Ex const &  ex)
noexcept

◆ trunc()

template<Expression Ex>
constexpr auto trunc ( Ex const &  ex)
constexprnoexcept

Computes Trunc of the given expression.

Example code:

auto a = variable{ random<float>( {2, 3, 5} ) };
auto b = trunc( a );
constexpr auto trunc(Ex const &ex) noexcept
Computes Trunc of the given expression.
Definition: operation.hpp:3806

◆ up_sampling_2d()

auto up_sampling_2d ( unsigned long  stride)
inlinenoexcept

◆ zero_padding_2d()

auto zero_padding_2d ( std::vector< unsigned long > const &  padding)
inlinenoexcept

Zero-padding layer for 2D input. The input should have 4-dimensions: (batch_size, row, col, channel). The output has 4-dimensions: (batch_size, new_row, new_col, channel).

Parameters
paddingIf a single integer, then apply symmetric padding to height and width. If two integers, then first is for height and the second is for width. If four integers, then is intepreted as<tt>(top_pad, bottom_pad, left_pad, right_pad).

Example code:

auto a = variable{ random<float>( {16, 16, 3} ) };
auto b = zero_padding_2d( {8,} )( a ); // shape for b is (8+16+8, 8+16+8, 3)
auto c = zero_padding_2d( {8, 4} )( a ); // shape for c is (8+16+8, 4+16+4, 3)
auto d = zero_padding_2d( {8, 4, 2, 1} )( a ); // shape for d is (8+16+4, 2+16+1, 3)
auto zero_padding_2d(std::vector< unsigned long > const &padding) noexcept
Zero-padding layer for 2D input. The input should have 4-dimensions: (batch_size, row,...
Definition: operation.hpp:1936

◆ zeros_like()

template<Expression Ex>
auto zeros_like ( Ex const &  ex)
noexcept

zeros_like produces a tensor of the same shape as the input expression, but with every element to be 0.

Returns
An unary operator that takes an unary operator, and producing an output tensor Example Code:
auto va = variable{ ones<float>({3, 3, 3}) };
auto v_rand = zeros_like( va ); // this expression will produces a tensor of shape (3, 3, 3), with every element to be 0.
auto zeros_like(Ex const &ex) noexcept
Definition: operation.hpp:1764

Variable Documentation

◆ sqr

* auto sqr = hypot( x, y )

◆ y

* auto y = variable<tensor<float>>{ }