Explorar o código

ConvolutionFeature: providing random parameters

Sven Sickert %!s(int64=10) %!d(string=hai) anos
pai
achega
3ff0c33bc9

+ 13 - 0
features/fpfeatures/ConvolutionFeature.cpp

@@ -6,6 +6,7 @@
 
 */
 #include <iostream>
+#include <time.h>
 
 #include "ConvolutionFeature.h"
 #include "vislearning/cbaselib/FeaturePool.h"
@@ -169,6 +170,18 @@ int ConvolutionFeature::getParameterLength() const
     return betaLength;
 }
 
+void ConvolutionFeature::setRandomParameterVector ( )
+{
+    srand (time(NULL));
+    for ( NICE::Vector::iterator it = beta->begin();
+          it != beta->end(); ++it )
+    {
+        double b = (double) rand() / (double) RAND_MAX;
+        *it = b;
+    }
+    beta->normalizeL2();
+}
+
 /** set parameter vector */
 void ConvolutionFeature::setParameterVector( const Vector & vec )
 {

+ 5 - 0
features/fpfeatures/ConvolutionFeature.h

@@ -104,6 +104,11 @@ class ConvolutionFeature : public Feature
      */
     void setParameterVector ( const NICE::Vector &vec );
 
+    /**
+     * @brief set a random parameter vector
+     */
+    void setRandomParameterVector ();
+
     /**
      * @brief return feature value for given example
      * @param example given Example