46 template <
size_t S1 = 1,
size_t S2 = 1,
size_t P1 = 0,
size_t P2 = 0, etl_expr A, etl_expr B>
71 template <etl_expr A, etl_expr B>
73 A&& a, B&& b,
size_t s1,
size_t s2,
size_t p1 = 0,
size_t p2 = 0) {
97 template <
size_t S1 = 1,
size_t S2 = 1,
size_t P1 = 0,
size_t P2 = 0, etl_expr A, etl_expr B>
122 template <etl_expr A, etl_expr B>
124 A&& a, B&& b,
size_t s1,
size_t s2,
size_t p1 = 0,
size_t p2 = 0) {
148 template <
size_t S1 = 1,
size_t S2 = 1,
size_t P1 = 0,
size_t P2 = 0, etl_expr A, etl_expr B>
173 template <etl_expr A, etl_expr B>
175 A&& a, B&& b,
size_t s1,
size_t s2,
size_t p1 = 0,
size_t p2 = 0) {
188 template <
size_t C1,
size_t C2,
size_t S1 = C1,
size_t S2 = C2,
size_t P1 = 0,
size_t P2 = 0,
typename E>
200 template <
typename E>
212 template <
typename E>
213 auto max_pool_forward(E&& value,
size_t c1,
size_t c2,
size_t s1,
size_t s2,
size_t p1 = 0,
size_t p2 = 0) {
225 template <
size_t C1,
size_t C2,
size_t C3,
typename E>
227 return pool_3d_expr<detail::build_type<E>, C1, C2, C3, C1, C2, C3, 0, 0, 0,
impl::max_pool_3d>{value};
238 template <
typename E>
240 return dyn_pool_3d_expr<detail::build_type<E>,
impl::max_pool_3d>{value, c1, c2, c3, c1, c2, c3, 0, 0, 0};
250 template <
size_t C1,
size_t C2,
size_t S1 = C1,
size_t S2 = C2,
size_t P1 = 0,
size_t P2 = 0,
typename E>
262 template <
typename E>
274 template <
typename E>
275 auto avg_pool_forward(E&& value,
size_t c1,
size_t c2,
size_t s1,
size_t s2,
size_t p1 = 0,
size_t p2 = 0) {
287 template <
size_t C1,
size_t C2,
size_t C3,
typename E>
289 return pool_3d_expr<detail::build_type<E>, C1, C2, C3, C1, C2, C3, 0, 0, 0,
impl::avg_pool_3d>{value};
300 template <
typename E>
302 return dyn_pool_3d_expr<detail::build_type<E>,
impl::avg_pool_3d>{value, c1, c2, c3, c1, c2, c3, 0, 0, 0};
313 template <
size_t C1,
size_t C2,
size_t S1,
size_t S2,
size_t P1,
size_t P2, etl_expr A, etl_expr B,
typename C>
314 pool_upsample_2d_expr<detail::build_type<A>, detail::build_type<B>,
detail::build_type<C>, C1, C2, S1, S2, P1, P2,
true>
max_pool_backward(A&& input, B&& output, C&& errors) {
315 return {input, output, errors};
326 template <etl_expr A, etl_expr B,
typename C>
328 A&& input, B&& output, C&& errors,
size_t c1,
size_t c2) {
329 return {input, output, errors, c1, c2, c1, c2, 0, 0};
340 template <etl_expr A, etl_expr B,
typename C>
342 A&& input, B&& output, C&& errors,
size_t c1,
size_t c2,
size_t s1,
size_t s2,
size_t p1 = 0,
size_t p2 = 0) {
343 return {input, output, errors, c1, c2, s1, s2, p1, p2};
354 template <
size_t C1,
size_t C2,
size_t C3, etl_expr A, etl_expr B,
typename C>
358 return {input, output, errors};
369 template <etl_expr A, etl_expr B,
typename C>
371 A&& input, B&& output, C&& errors,
size_t c1,
size_t c2,
size_t c3) {
372 return {input, output, errors, c1, c2, c3};
383 template <
size_t C1,
size_t C2,
size_t S1,
size_t S2,
size_t P1,
size_t P2, etl_expr A, etl_expr B,
typename C>
384 pool_upsample_2d_expr<detail::build_type<A>, detail::build_type<B>, detail::build_type<C>, C1, C2, S1, S2, P1, P2,
false>
avg_pool_backward(A&& input, B&& output, C&& errors) {
385 return {input, output, errors};
396 template <etl_expr A, etl_expr B,
typename C>
398 A&& input, B&& output, C&& errors,
size_t c1,
size_t c2) {
399 return {input, output, errors, c1, c2, c1, c2, 0, 0};
410 template <etl_expr A, etl_expr B,
typename C>
412 A&& input, B&& output, C&& errors,
size_t c1,
size_t c2,
size_t s1,
size_t s2,
size_t p1 = 0,
size_t p2 = 0) {
413 return {input, output, errors, c1, c2, s1, s2, p1, p2};
424 template <
size_t C1,
size_t C2,
size_t C3, etl_expr A, etl_expr B,
typename C>
428 return {input, output, errors};
439 template <etl_expr A, etl_expr B,
typename C>
441 A&& input, B&& output, C&& errors,
size_t c1,
size_t c2,
size_t c3) {
442 return {input, output, errors, c1, c2, c3};
452 template <
typename E>
463 template <etl_expr E>
465 return value >> (1.0 - value);
474 template <
typename E>
485 template <etl_expr E>
487 return 1.0 - (value >> value);
496 template <etl_expr E>
509 template <
typename O,
typename E>
510 decltype(
auto) identity_backward([[maybe_unused]] O&& output, E&& errors) {
511 return std::forward<E>(errors);
520 template <
typename O,
typename E>
522 return {output, errors};
531 template <
typename O,
typename E>
533 return {output, errors};
542 template <
typename O,
typename E>
543 decltype(
auto) softmax_backward([[maybe_unused]] O&& output, E&& errors) {
544 return std::forward<E>(errors);
553 template <
typename O, etl_expr E>
555 return (1.0 - (output >> output)) >> errors;
564 template <etl_expr O, etl_expr L>
575 template <etl_expr O, etl_expr L>
586 template <etl_expr O, etl_expr L>
597 template <etl_expr O, etl_expr L>
608 template <etl_expr O, etl_expr L>
619 template <etl_expr O, etl_expr L>
630 template <etl_expr O, etl_expr L>
641 template <etl_expr O, etl_expr L>
652 template <etl_expr O, etl_expr L>
A transposition expression.
Definition: dyn_pool_2d_expr.hpp:19
Selector for the Categorical Cross Entropy reduction implementations.
static std::pair< value_t< O >, value_t< O > > apply(const O &output, const L &labels, value_t< O > alpha, value_t< O > beta)
Apply the functor to e.
Definition: cce.hpp:77
value_t< O > cce_loss(O &&output, L &&labels, value_t< O > scale)
Returns the Categorical Cross Entropy Loss.
Definition: ml_expression_builder.hpp:565
Expression representing a batch of transposed 2D convolution of an batch of image with a set of kerne...
Definition: conv_4d_backward_expr.hpp:44
auto max_pool_forward(E &&value)
Forward 2D Max Pooling of the given matrix expression.
Definition: ml_expression_builder.hpp:189
value_t< O > mse_error(O &&output, L &&labels, value_t< O > scale)
Returns the Binary Cross Entropy Error.
Definition: ml_expression_builder.hpp:642
std::pair< value_t< O >, value_t< O > > bce(O &&output, L &&labels, value_t< O > alpha, value_t< O > beta)
Returns the Binary Cross Entropy Loss and Error.
Definition: ml_expression_builder.hpp:609
auto max_pool_3d_forward(E &&value)
Forward 3D Max Pooling of the given matrix expression.
Definition: ml_expression_builder.hpp:226
auto sigmoid_derivative_out(E &&value) -> decltype(value >>(1.0 - value))
Return the derivative of the logistic sigmoid of the given ETL expression, with respect to the output...
Definition: ml_expression_builder.hpp:464
static std::pair< value_t< O >, value_t< O > > apply(const O &output, const L &labels, value_t< O > alpha, value_t< O > beta)
Apply the functor to e.
Definition: mse.hpp:77
Functor for 2D Average Pooling.
Definition: pooling.hpp:174
A transposition expression.
Definition: pool_2d_expr.hpp:23
pool_upsample_2d_expr< detail::build_type< A >, detail::build_type< B >, detail::build_type< C >, C1, C2, S1, S2, P1, P2, true > max_pool_backward(A &&input, B &&output, C &&errors)
Derivative of the 2D Max Pooling of the given matrix expression and upsampling.
Definition: ml_expression_builder.hpp:314
pool_upsample_2d_expr< detail::build_type< A >, detail::build_type< B >, detail::build_type< C >, C1, C2, S1, S2, P1, P2, false > avg_pool_backward(A &&input, B &&output, C &&errors)
Derivative of the 2D Avg Pooling of the given matrix expression and upsampling.
Definition: ml_expression_builder.hpp:384
A derivative of the max pooling (combine derivative and upsampling for performance) ...
Definition: pool_upsample_3d_expr.hpp:26
conv_4d_backward_filter_expr< detail::build_type< A >, detail::build_type< B >, S1, S2, P1, P2, true > convolution_backward_filter(A &&a, B &&b)
Backward convolution for a batch of images with a set of kernels.
Definition: ml_expression_builder.hpp:149
auto tanh_backward(O &&output, E &&errors)
Return the backward activation of the tanh function.
Definition: ml_expression_builder.hpp:554
Expression representing a batch of transposed 2D convolution of an batch of image with a set of kerne...
Definition: dyn_conv_4d_backward_expr.hpp:40
auto relu_backward(O &&output, E &&errors) -> detail::left_binary_helper< O, E, relu_derivative_binary_op >
Return the backward activation of the RELU function.
Definition: ml_expression_builder.hpp:532
static value_t< O > apply(const O &output, const L &labels, value_t< O > scale)
Apply the functor to e.
Definition: mse.hpp:137
auto sigmoid_backward(O &&output, E &&errors) -> detail::left_binary_helper< O, E, sigmoid_derivative_binary_op >
Return the backward activation of the sigmoid function.
Definition: ml_expression_builder.hpp:521
An unary expression.
Definition: unary_expr.hpp:126
A derivative of the 2D max pooling (combine derivative and upsampling for performance) ...
Definition: dyn_pool_upsample_2d_expr.hpp:26
auto avg_pool_forward(E &&value)
Forward Average Pooling of the given matrix expression.
Definition: ml_expression_builder.hpp:251
A binary expression.
Definition: binary_expr.hpp:18
std::pair< value_t< O >, value_t< O > > mse(O &&output, L &&labels, value_t< O > alpha, value_t< O > beta)
Returns the Binary Cross Entropy Loss and Error.
Definition: ml_expression_builder.hpp:653
A transposition expression.
Definition: dyn_pool_3d_expr.hpp:19
static value_t< O > apply(const O &output, const L &labels, value_t< O > scale)
Apply the functor to e.
Definition: mse.hpp:107
A transposition expression.
Definition: conv_4d_valid_expr.hpp:22
Functor for 2D Max Pooling.
Definition: pooling.hpp:94
static value_t< O > apply(const O &output, const L &labels, value_t< O > scale)
Apply the functor to e.
Definition: bce.hpp:137
std::conditional_t< is_etl_value< T >, const std::decay_t< T > &, std::decay_t< T > > build_type
Helper to build the type for a sub expression.
Definition: expression_helpers.hpp:24
Definition: ml_expression_builder.hpp:22
std::pair< value_t< O >, value_t< O > > cce(O &&output, L &&labels, value_t< O > alpha, value_t< O > beta)
Returns the Categorical Cross Entropy Loss and Error.
Definition: ml_expression_builder.hpp:620
auto scale(LE &&lhs, RE &&rhs)
Builds an expression representing the scalar multiplication of lhs and rhs.
Definition: binary_expression_builder.hpp:64
auto tanh_derivative_out(E &&value) -> decltype(1.0 -(value >> value))
Return the derivative of the tanh function of the given ETL expression, with respect to the output va...
Definition: ml_expression_builder.hpp:486
Selector for the Binary Cross Entropy reduction implementations.
value_t< O > bce_error(O &&output, L &&labels, value_t< O > scale)
Returns the Binary Cross Entropy Error.
Definition: ml_expression_builder.hpp:598
static std::pair< value_t< O >, value_t< O > > apply(const O &output, const L &labels, value_t< O > alpha, value_t< O > beta)
Apply the functor to e.
Definition: bce.hpp:77
value_t< O > mse_loss(O &&output, L &&labels, value_t< O > scale)
Returns the Binary Cross Entropy Loss.
Definition: ml_expression_builder.hpp:631
auto relu_derivative_out(const E &value) -> detail::unary_helper< E, relu_derivative_op >
Return the derivative of the relu function of the given ETL expression, with respect for the output v...
Definition: ml_expression_builder.hpp:497
conv_4d_valid_expr< detail::build_type< A >, detail::build_type< B >, S1, S2, P1, P2, true > convolution_forward(A &&a, B &&b)
Forward convolution for a batch of images with a set of kernels.
Definition: ml_expression_builder.hpp:47
A transposition expression.
Definition: dyn_conv_4d_valid_expr.hpp:22
pool_upsample_3d_expr< detail::build_type< A >, detail::build_type< B >, detail::build_type< C >, C1, C2, C3, true > max_pool_3d_backward(A &&input, B &&output, C &&errors)
Derivative of the 3D Max Pooling of the given matrix expression and upsampling.
Definition: ml_expression_builder.hpp:355
static value_t< O > apply(const O &output, const L &labels, value_t< O > scale)
Apply the functor to e.
Definition: bce.hpp:107
Functor for 3D Average Pooling.
Definition: pooling.hpp:334
auto avg_pool_3d_forward(E &&value)
Forward 3D Average Pooling of the given matrix expression.
Definition: ml_expression_builder.hpp:288
A transposition expression.
Definition: pool_3d_expr.hpp:19
static value_t< O > apply(const O &output, const L &labels, value_t< O > scale)
Apply the functor to e.
Definition: cce.hpp:137
auto identity_derivative_out([[maybe_unused]] E &&value)
Return the derivative of the identiy function for the given output value.
Definition: ml_expression_builder.hpp:453
pool_upsample_3d_expr< detail::build_type< A >, detail::build_type< B >, detail::build_type< C >, C1, C2, C3, false > avg_pool_3d_backward(A &&input, B &&output, C &&errors)
Derivative of the 2D Avg Pooling of the given matrix expression and upsampling.
Definition: ml_expression_builder.hpp:425
A transposition expression.
Definition: conv_4d_backward_filter_expr.hpp:22
A derivative of the 2D max pooling (combine derivative and upsampling for performance) ...
Definition: pool_upsample_2d_expr.hpp:26
value_t< O > bce_loss(O &&output, L &&labels, value_t< O > scale)
Returns the Binary Cross Entropy Loss.
Definition: ml_expression_builder.hpp:587
value_t< O > cce_error(O &&output, L &&labels, value_t< O > scale)
Returns the Categorical Cross Entropy Error.
Definition: ml_expression_builder.hpp:576
typename decay_traits< E >::value_type value_t
Traits to extract the value type out of an ETL type.
Definition: tmp.hpp:81
auto softmax_derivative_out([[maybe_unused]] E &&e)
Return the derivative of the softmax function of the given ETL expression, with respect to output val...
Definition: ml_expression_builder.hpp:475
Expression representing a batch of transposed 2D convolution of an batch of image with a set of kerne...
Definition: dyn_conv_4d_backward_filter_expr.hpp:40
Functor for 3D Max Pooling.
Definition: pooling.hpp:254
A derivative of the 3D max pooling (combine derivative and upsampling for performance) ...
Definition: dyn_pool_upsample_3d_expr.hpp:26
conv_4d_backward_expr< detail::build_type< A >, detail::build_type< B >, S1, S2, P1, P2, true > convolution_backward(A &&a, B &&b)
Backward convolution for a batch of images with a set of kernels.
Definition: ml_expression_builder.hpp:98
Selector for the Mean Squared Error reduction implementations.
static value_t< O > apply(const O &output, const L &labels, value_t< O > scale)
Apply the functor to e.
Definition: cce.hpp:107