Blaze
3.9
Toggle main menu visibility
Loading...
Searching...
No Matches
blaze
math
expressions
DVecSoftmaxExpr.h
Go to the documentation of this file.
1
//=================================================================================================
33
//=================================================================================================
34
35
#ifndef _BLAZE_MATH_EXPRESSIONS_DVECSOFTMAXEXPR_H_
36
#define _BLAZE_MATH_EXPRESSIONS_DVECSOFTMAXEXPR_H_
37
38
39
//*************************************************************************************************
40
// Includes
41
//*************************************************************************************************
42
43
#include <
blaze/math/expressions/DenseVector.h
>
44
45
46
namespace
blaze {
47
48
//=================================================================================================
49
//
50
// GLOBAL FUNCTIONS
51
//
52
//=================================================================================================
53
54
//*************************************************************************************************
65
template
<
typename
VT
// Type of the dense vector
66
,
bool
TF >
// Transpose flag
67
auto
softmax
(
const
DenseVector<VT,TF>
& dv )
68
{
69
auto
tmp(
evaluate
(
exp
( *dv -
max
( *dv ) ) ) );
70
const
auto
scalar(
sum
( *tmp ) );
71
tmp /= scalar;
72
return
tmp;
73
}
74
//*************************************************************************************************
75
76
}
// namespace blaze
77
78
#endif
blaze::DenseVector
Base class for N-dimensional dense vectors.
Definition
DenseVector.h:77
DenseVector.h
Header file for the DenseVector base class.
blaze::exp
decltype(auto) exp(const DenseMatrix< MT, SO > &dm)
Computes for each single element of the dense matrix dm.
Definition
DMatMapExpr.h:1801
blaze::max
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition
DMatDMatMapExpr.h:1375
blaze::sum
decltype(auto) sum(const DenseMatrix< MT, SO > &dm)
Reduces the given dense matrix by means of addition.
Definition
DMatReduceExpr.h:2156
blaze::softmax
auto softmax(const DenseMatrix< MT, SO > &dm)
Computes the softmax function for the given dense matrix.
Definition
DMatSoftmaxExpr.h:88
blaze::evaluate
MT::ResultType evaluate(const Matrix< MT, SO > &matrix)
Evaluates the given matrix expression.
Definition
Matrix.h:1282
Generated by
1.18.0