Activation

Berechnen der Aktivierungsfunktion und zuweisen der Werte dem übergebenen Vektor bzw. Matrix.

bool vector::Activation(
  vector&                   vect_out,      // Vektor für die Werte
  ENUM_ACTIVATION_FUNCTION  activation,    // Aktivierungsfunktion
   ...                                     // weitere Parameter
   );
 
 
bool matrix::Activation(
  matrix&                   matrix_out,    // Matrix für die Werte
  ENUM_ACTIVATION_FUNCTION  activation     // Aktivierungsfunktion
   );
 
 
bool matrix::Activation(
  matrix&                   matrix_out,    // Matrix für die Werte
  ENUM_ACTIVATION_FUNCTION  activation,    // Aktivierungsfunktion
  ENUM_MATRIX_AXIS          axis,          // Achse
   ...                                     // weitere Parameter
   );

Parameter

vect_out/matrix_out

[out]  Vektor oder Matrix für die berechneten Werte der Aktivierungsfunktion.

activation

[in]  Aktivierungsfunktion aus der Enumeration ENUM_ACTIVATION_FUNCTION.

axis

[in] ENUM_MATRIX_AXIS Wert der Enumeration (AXIS_HORZ — horizontale Achse, AXIS_VERT — vertikale Achse).

...

[in]  Weitere Parameter, die für einige Aktivierungsfunktionen erforderlich sind. Wenn keine Parameter angegeben werden, werden die Standardwerte verwendet.

Rückgabewert

Liefert bei Erfolg true, ansonsten false.

Weitere Parameter

Einige Aktivierungsfunktionen akzeptieren zusätzliche Parameter. Wenn keine Parameter angegeben sind, werden die Standardwerte verwendet.

   AF_ELU  (Exponential Linear Unit)  
     double alpha=1.0
   
   Aktivierungsfunktion: if(x>=0f(x) = x
                      else f(x) = alpha * (exp(x)-1)
   
   
   AF_LINEAR   
     double alpha=1.0
     double beta=0.0
   
   Aktivierungsfunktion: f(x) = alpha*x + beta
   
   
   AF_LRELU   (Leaky REctified Linear Unit)   
     double alpha=0.3
   
   Aktivierungsfunktion: if(x>=0f(x)=x
                      else f(x) = alpha*x
   
                        
   AF_RELU  (REctified Linear Unit)   
     double alpha=0.0
     double max_value=0.0
     double treshold=0.0
   
   Aktivierungsfunktion: if(alpha==0f(x) = max(x,0)
                      else if(x>max_valuef(x) = x
                      else f(x) = alpha*(x - treshold)
   
   
   AF_SWISH   
     double beta=1.0
   
   Aktivierungsfunktion: f(x) = x / (1+exp(-x*beta))
   
   
   AF_TRELU   (Thresholded REctified Linear Unit)   
     double theta=1.0
   
   Aktivierungsfunktion: if(x>thetaf(x) = x
                      else f(x) = 0
   
   
   AF_PRELU   (Parametric REctified Linear Unit)   
     double alpha[] - learned array of coeefficients
   
   Aktivierungsfunktion: if(x[i]>=0f(x)[i] = x[i]
                      else f(x)[i] = alpha[i] * x[i]

Hinweis

In künstlichen neuronalen Netzen bestimmt die Aktivierungsfunktion eines Neurons das Ausgangssignal, das durch ein Eingangssignal oder einen Satz von Eingangssignalen definiert ist. Die Wahl der Aktivierungsfunktion hat einen großen Einfluss auf die Leistung des neuronalen Netzes. Verschiedene Modellteile (Schichten) können unterschiedliche Aktivierungsfunktionen verwenden.

Beispiele für die Verwendung zusätzlicher Parameter:

   vector x={0.10.40.92.0, -5.00.0, -0.1};
   vector y;
 
   x.Activation(y,AF_ELU);
   Print(y);
   x.Activation(y,AF_ELU,2.0);
   Print(y);
 
   Print("");
   x.Activation(y,AF_LINEAR);
   Print(y);
   x.Activation(y,AF_LINEAR,2.0);
   Print(y);
   x.Activation(y,AF_LINEAR,2.0,5.0);
   Print(y);
 
   Print("");
   x.Activation(y,AF_LRELU);
   Print(y);
   x.Activation(y,AF_LRELU,1.0);
   Print(y);
   x.Activation(y,AF_LRELU,0.1);
   Print(y);
  
   Print("");
   x.Activation(y,AF_RELU);
   Print(y);
   x.Activation(y,AF_RELU,2.0,0.5);
   Print(y);
   x.Activation(y,AF_RELU,2.0,0.5,1.0);
   Print(y);
 
   Print("");
   x.Activation(y,AF_SWISH);
   Print(y);
   x.Activation(y,AF_SWISH,2.0);
   Print(y);
 
   Print("");
   x.Activation(y,AF_TRELU);
   Print(y);
   x.Activation(y,AF_TRELU,0.3);
   Print(y);
 
   Print("");
   vector a=vector::Full(x.Size(),2.0);
   x.Activation(y,AF_PRELU,a);
   Print(y);
 
/*  Ergebnisse
   [0.1,0.4,0.9,2,-0.993262053000915,0,-0.095162581964040]
   [0.1,0.4,0.9,2,-1.986524106001829,0,-0.190325163928081]
   
   [0.1,0.4,0.9,2,-5,0,-0.1]
   [0.2,0.8,1.8,4,-10,0,-0.2]
   [5.2,5.8,6.8,9,-5,5,4.8]
   
   [0.1,0.4,0.9,2,-1.5,0,-0.03]
   [0.1,0.4,0.9,2,-5,0,-0.1]
   [0.1,0.4,0.9,2,-0.5,0,-0.01]
   
   [0.1,0.4,0.9,2,0,0,0]
   [0.2,0.8,0.9,2,-10,0,-0.2]
   [-1.8,-1.2,0.9,2,-12,-2,-2.2]
   
   [0.052497918747894,0.239475064044981,0.6398545523625035,1.761594155955765,-0.03346425462142428,0,-0.047502081252106]
   [0.054983399731247,0.275989792451045,0.7723340415895611,1.964027580075817,-0.00022698934351217,0,-0.045016600268752]
   
   [0,0,0,2,0,0,0]
   [0,0.4,0.9,2,0,0,0]
   
   [0.1,0.4,0.9,2,-10,0,-0.2]
*/