mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
ml: apply CV_OVERRIDE/CV_FINAL
This commit is contained in:
+43
-32
@@ -213,7 +213,7 @@ void ANN_MLP::setAnnealEnergyRNG(const RNG& rng)
|
||||
this_->setAnnealEnergyRNG(rng);
|
||||
}
|
||||
|
||||
class ANN_MLPImpl : public ANN_MLP_ANNEAL
|
||||
class ANN_MLPImpl CV_FINAL : public ANN_MLP_ANNEAL
|
||||
{
|
||||
public:
|
||||
ANN_MLPImpl()
|
||||
@@ -226,23 +226,34 @@ public:
|
||||
|
||||
virtual ~ANN_MLPImpl() {}
|
||||
|
||||
CV_IMPL_PROPERTY(TermCriteria, TermCriteria, params.termCrit)
|
||||
CV_IMPL_PROPERTY(double, BackpropWeightScale, params.bpDWScale)
|
||||
CV_IMPL_PROPERTY(double, BackpropMomentumScale, params.bpMomentScale)
|
||||
CV_IMPL_PROPERTY(double, RpropDW0, params.rpDW0)
|
||||
CV_IMPL_PROPERTY(double, RpropDWPlus, params.rpDWPlus)
|
||||
CV_IMPL_PROPERTY(double, RpropDWMinus, params.rpDWMinus)
|
||||
CV_IMPL_PROPERTY(double, RpropDWMin, params.rpDWMin)
|
||||
CV_IMPL_PROPERTY(double, RpropDWMax, params.rpDWMax)
|
||||
CV_IMPL_PROPERTY(double, AnnealInitialT, params.initialT)
|
||||
CV_IMPL_PROPERTY(double, AnnealFinalT, params.finalT)
|
||||
CV_IMPL_PROPERTY(double, AnnealCoolingRatio, params.coolingRatio)
|
||||
CV_IMPL_PROPERTY(int, AnnealItePerStep, params.itePerStep)
|
||||
inline TermCriteria getTermCriteria() const CV_OVERRIDE { return params.termCrit; }
|
||||
inline void setTermCriteria(TermCriteria val) CV_OVERRIDE { params.termCrit = val; }
|
||||
inline double getBackpropWeightScale() const CV_OVERRIDE { return params.bpDWScale; }
|
||||
inline void setBackpropWeightScale(double val) CV_OVERRIDE { params.bpDWScale = val; }
|
||||
inline double getBackpropMomentumScale() const CV_OVERRIDE { return params.bpMomentScale; }
|
||||
inline void setBackpropMomentumScale(double val) CV_OVERRIDE { params.bpMomentScale = val; }
|
||||
inline double getRpropDW0() const CV_OVERRIDE { return params.rpDW0; }
|
||||
inline void setRpropDW0(double val) CV_OVERRIDE { params.rpDW0 = val; }
|
||||
inline double getRpropDWPlus() const CV_OVERRIDE { return params.rpDWPlus; }
|
||||
inline void setRpropDWPlus(double val) CV_OVERRIDE { params.rpDWPlus = val; }
|
||||
inline double getRpropDWMinus() const CV_OVERRIDE { return params.rpDWMinus; }
|
||||
inline void setRpropDWMinus(double val) CV_OVERRIDE { params.rpDWMinus = val; }
|
||||
inline double getRpropDWMin() const CV_OVERRIDE { return params.rpDWMin; }
|
||||
inline void setRpropDWMin(double val) CV_OVERRIDE { params.rpDWMin = val; }
|
||||
inline double getRpropDWMax() const CV_OVERRIDE { return params.rpDWMax; }
|
||||
inline void setRpropDWMax(double val) CV_OVERRIDE { params.rpDWMax = val; }
|
||||
inline double getAnnealInitialT() const CV_OVERRIDE { return params.initialT; }
|
||||
inline void setAnnealInitialT(double val) CV_OVERRIDE { params.initialT = val; }
|
||||
inline double getAnnealFinalT() const CV_OVERRIDE { return params.finalT; }
|
||||
inline void setAnnealFinalT(double val) CV_OVERRIDE { params.finalT = val; }
|
||||
inline double getAnnealCoolingRatio() const CV_OVERRIDE { return params.coolingRatio; }
|
||||
inline void setAnnealCoolingRatio(double val) CV_OVERRIDE { params.coolingRatio = val; }
|
||||
inline int getAnnealItePerStep() const CV_OVERRIDE { return params.itePerStep; }
|
||||
inline void setAnnealItePerStep(int val) CV_OVERRIDE { params.itePerStep = val; }
|
||||
// disabled getAnnealEnergyRNG()
|
||||
inline void setAnnealEnergyRNG(const RNG& val) CV_OVERRIDE { params.rEnergy = val; }
|
||||
|
||||
//CV_IMPL_PROPERTY(RNG, AnnealEnergyRNG, params.rEnergy)
|
||||
inline void setAnnealEnergyRNG(const RNG& val) { params.rEnergy = val; }
|
||||
|
||||
void clear()
|
||||
void clear() CV_OVERRIDE
|
||||
{
|
||||
min_val = max_val = min_val1 = max_val1 = 0.;
|
||||
rng = RNG((uint64)-1);
|
||||
@@ -253,7 +264,7 @@ public:
|
||||
|
||||
int layer_count() const { return (int)layer_sizes.size(); }
|
||||
|
||||
void setTrainMethod(int method, double param1, double param2)
|
||||
void setTrainMethod(int method, double param1, double param2) CV_OVERRIDE
|
||||
{
|
||||
if (method != ANN_MLP::RPROP && method != ANN_MLP::BACKPROP && method != ANN_MLP::ANNEAL)
|
||||
method = ANN_MLP::RPROP;
|
||||
@@ -276,12 +287,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
int getTrainMethod() const
|
||||
int getTrainMethod() const CV_OVERRIDE
|
||||
{
|
||||
return params.trainMethod;
|
||||
}
|
||||
|
||||
void setActivationFunction(int _activ_func, double _f_param1, double _f_param2)
|
||||
void setActivationFunction(int _activ_func, double _f_param1, double _f_param2) CV_OVERRIDE
|
||||
{
|
||||
if( _activ_func < 0 || _activ_func > LEAKYRELU)
|
||||
CV_Error( CV_StsOutOfRange, "Unknown activation function" );
|
||||
@@ -362,12 +373,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
Mat getLayerSizes() const
|
||||
Mat getLayerSizes() const CV_OVERRIDE
|
||||
{
|
||||
return Mat_<int>(layer_sizes, true);
|
||||
}
|
||||
|
||||
void setLayerSizes( InputArray _layer_sizes )
|
||||
void setLayerSizes( InputArray _layer_sizes ) CV_OVERRIDE
|
||||
{
|
||||
clear();
|
||||
|
||||
@@ -399,7 +410,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
float predict( InputArray _inputs, OutputArray _outputs, int ) const
|
||||
float predict( InputArray _inputs, OutputArray _outputs, int ) const CV_OVERRIDE
|
||||
{
|
||||
if( !trained )
|
||||
CV_Error( CV_StsError, "The network has not been trained or loaded" );
|
||||
@@ -907,7 +918,7 @@ public:
|
||||
calc_output_scale( outputs, flags );
|
||||
}
|
||||
|
||||
bool train( const Ptr<TrainData>& trainData, int flags )
|
||||
bool train( const Ptr<TrainData>& trainData, int flags ) CV_OVERRIDE
|
||||
{
|
||||
const int MAX_ITER = 1000;
|
||||
const double DEFAULT_EPSILON = FLT_EPSILON;
|
||||
@@ -1108,7 +1119,7 @@ public:
|
||||
int dcount0;
|
||||
double* pE;
|
||||
|
||||
void operator()( const Range& range ) const
|
||||
void operator()(const Range& range) const CV_OVERRIDE
|
||||
{
|
||||
double inv_count = 1./inputs.rows;
|
||||
int ivcount = ann->layer_sizes.front();
|
||||
@@ -1392,7 +1403,7 @@ public:
|
||||
fs << "}" << "}";
|
||||
}
|
||||
|
||||
void write( FileStorage& fs ) const
|
||||
void write( FileStorage& fs ) const CV_OVERRIDE
|
||||
{
|
||||
if( layer_sizes.empty() )
|
||||
return;
|
||||
@@ -1502,7 +1513,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void read( const FileNode& fn )
|
||||
void read( const FileNode& fn ) CV_OVERRIDE
|
||||
{
|
||||
clear();
|
||||
|
||||
@@ -1531,28 +1542,28 @@ public:
|
||||
trained = true;
|
||||
}
|
||||
|
||||
Mat getWeights(int layerIdx) const
|
||||
Mat getWeights(int layerIdx) const CV_OVERRIDE
|
||||
{
|
||||
CV_Assert( 0 <= layerIdx && layerIdx < (int)weights.size() );
|
||||
return weights[layerIdx];
|
||||
}
|
||||
|
||||
bool isTrained() const
|
||||
bool isTrained() const CV_OVERRIDE
|
||||
{
|
||||
return trained;
|
||||
}
|
||||
|
||||
bool isClassifier() const
|
||||
bool isClassifier() const CV_OVERRIDE
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int getVarCount() const
|
||||
int getVarCount() const CV_OVERRIDE
|
||||
{
|
||||
return layer_sizes.empty() ? 0 : layer_sizes[0];
|
||||
}
|
||||
|
||||
String getDefaultName() const
|
||||
String getDefaultName() const CV_OVERRIDE
|
||||
{
|
||||
return "opencv_ml_ann_mlp";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user