ATLAS Offline Software
Public Member Functions | List of all members
lwtDev::SoftmaxLayer Class Reference

#include <Stack.h>

Inheritance diagram for lwtDev::SoftmaxLayer:
Collaboration diagram for lwtDev::SoftmaxLayer:

Public Member Functions

virtual VectorXd compute (const VectorXd &) const override
 

Detailed Description

Definition at line 100 of file Stack.h.

Member Function Documentation

◆ compute()

VectorXd lwtDev::SoftmaxLayer::compute ( const VectorXd &  in) const
overridevirtual

Implements lwtDev::ILayer.

Definition at line 182 of file Stack.cxx.

182  {
183  // More numerically stable softmax, as suggested in
184  // http://stackoverflow.com/a/34969389
185  size_t n_elements = in.rows();
186  VectorXd exp(n_elements);
187  double max = in.maxCoeff();
188  for (size_t iii = 0; iii < n_elements; iii++) {
189  exp(iii) = std::exp(in(iii) - max);
190  }
191  double sum_exp = exp.sum();
192  return exp / sum_exp;
193  }

The documentation for this class was generated from the following files:
max
#define max(a, b)
Definition: cfImp.cxx:41
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36