49 template<
typename dtype>
59 returnArray /=
static_cast<double>(returnArray.sum().item());
65 auto expSums = returnArray.sum(inAxis);
67 for (
uint32 row = 0; row < returnArray.shape().rows; ++row)
69 const auto rowExpSum =
static_cast<double>(expSums[row]);
72 [rowExpSum](
double& value) { value /= rowExpSum; });
80 auto expSums = returnArray.sum(
Axis::COL);
82 for (
uint32 row = 0; row < returnArray.shape().rows; ++row)
84 const auto rowExpSum =
static_cast<double>(expSums[row]);
87 [rowExpSum](
double& value) { value /= rowExpSum; });
90 return returnArray.transpose();
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition StaticAsserts.hpp:39
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
self_type transpose() const
Definition NdArrayCore.hpp:4963
Definition airy_ai.hpp:39
NdArray< double > softmax(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition softmax.hpp:50
void for_each(InputIt first, InputIt last, UnaryFunction f)
Definition StlAlgorithms.hpp:226
Axis
Enum To describe an axis.
Definition Enums.hpp:36
@ ROW
Definition Enums.hpp:38
@ COL
Definition Enums.hpp:39
@ NONE
Definition Enums.hpp:37
auto exp(dtype inValue) noexcept
Definition exp.hpp:49
NdArray< dtypeOut > astype(const NdArray< dtype > inArray)
Definition astype.hpp:45
std::uint32_t uint32
Definition Types.hpp:40