 |
Belle II Software
release-05-02-19
|
12 #ifndef _SVD_RECONSTRUCTION_NNwAVEFITTER_H
13 #define _SVD_RECONSTRUCTION_NNWAVEFITTER_H
21 #include <svd/reconstruction/NNWaveFitTool.h>
22 #include <svd/simulation/SVDSimulationTools.h>
23 #include <Eigen/Dense>
94 std::shared_ptr<nnFitterBinData>
getFit(
const apvSamples& samples,
double tau);
148 [](
double x) ->
double {
return std::max(
double(0.0), x); };
151 [](
double x) ->
double {
double e = std::exp(x);
return e / (1.0 + e); };
157 Eigen::VectorXd
softmax(
const Eigen::VectorXd& input)
159 auto output = input.array().unaryExpr(
160 [](
double x)->
double {
return ((x > 0.0) ? exp(x) : 0.0); }
162 double norm = output.sum();
163 return output / norm;
175 typedef std::map< size_t, std::pair< Eigen::MatrixXd, Eigen::VectorXd > >
const NNWaveFitTool & getFitTool() const
Get a handle to a NNWaveFit object.
TauEncoder m_tauCoder
Tau encoder class instance to scale tau values.
std::function< double(double)> waveFunction
Wavefrom function type.
Encoder/decoder for neural network tau values.
activationType m_activation
Network activation function.
const nnFitterBinData & getBinCenters() const
Get bin times of the network output.
std::vector< std::size_t > m_layerSizes
NN layer sizes.
networkWeightsType m_networkCoefs
NN weights and intercepts.
std::map< size_t, std::pair< Eigen::MatrixXd, Eigen::VectorXd > > networkWeightsType
We use map to store network layers since we don't know if we'll be reading them in correct order.
std::pair< double, double > nnBoundsType
Bounds type used to hold network parameter bounds used in training the network.
nnFitterBins m_bins
NN time bin boundaries.
Eigen::VectorXd softmax(const Eigen::VectorXd &input)
Softmax function, normalization for the network's output layer.
int readNetworkData(const std::string &xmlFileName)
The method that actually reads the xml file.
std::vector< Eigen::VectorXd > layerStatesType
Storage for internal states.
The class uses a neural network to find a probability distribution of arrival times for a sextet of A...
nnBoundsType getAmplitudeBounds() const
Get amplitude bounds.
bool checkCoefficients(const std::string &dumpname, double tol=1.0e-10)
Check NN data against a dump from Python.
nnBoundsType getWaveWidthBounds() const
Get width bounds Width bounds are minimum and maximum width used in training the network.
waveFunction m_wave
Wave function used in training the network.
std::vector< double > nnFitterBins
Vector of bin edges, nnFitterBinData.size() + 1.
Abstract base class for different kinds of events.
std::array< apvSampleBaseType, nAPVSamples > apvSamples
vector od apvSample BaseType objects
layerStatesType m_layerStates
vectors of layer states
std::size_t m_nLayers
number of NN layers, read from xml
activationType sigmoid
Sigmoid activation.
bool m_isValid
true if fitter was properly initialized
void setNetwrok(const std::string &xmlData)
Set proper network definition file.
nnFitterBinData m_binCenters
centers of NN time bins
const nnFitterBins & getBins() const
Get bins of netwrok output.
nnBoundsType getTimeShiftBounds() const
Get time shift bounds.
std::function< double(double)> activationType
Activation functions type.
std::vector< double > nnFitterBinData
Vector of values defined for bins, such as bin times or bin probabilities.
std::shared_ptr< NNWaveFitTool > m_fitTool
FitterTool object allowing calculations on network fits.
nnBoundsType m_timeShiftBounds
Time shift range of the network.
nnBoundsType m_waveWidthBounds
Waveform width range of the network.
activationType relu
Rectifier activation.
nnBoundsType m_amplitudeBounds
Amplitude range of the network.
NNWaveFitter(std::string xmlData="")
Constructor constructs the wavefitter from data in xml file.
bool isValid() const
Is this fitter working? Return false if the fitter was not initialized properly.
std::shared_ptr< nnFitterBinData > getFit(const apvSamples &samples, double tau)
Fitting method Send data and get rseult structure.