Math Vector Library 1.1 Machine Learning Extension
Programming Reference Manual C/C++
Version 1.1 DD-00004-011

4.6 vmlrelud - ReLU activation (first derivative)

#include <mvecml.h> 
 
void vmlrelud (int n, double *restrict y, int incy, const double *restrict x, int incx); 
void vmlreludf(int n, float *restrict y, int incy, const float *restrict x, int incx); 
 
 
#include <mvecml64.h> 
 
void vmlrelud_64(long n, double *restrict y, long incy, const double *restrict x, long incx); 
void vmlreludf_64(long n, float *restrict y, long incy, const float *restrict x, long incx);

Given an input vector x and a result vector y this function computes the first derivative of the ReLU activation function of the values in the x vector and stores the result in the y vector.

   {
y .=  0 where x< 0∨ x= 0
     1 where x> 0

The case where x =0 is normally undefined, for proper behavior in the application scenario of machine learning this function substitutes 0 as a result on those elements to handle this condition gracefully.

4.6.1 Parameters

N - INTEGER

ENTRY: Number of elements of x and y.
CONSTRAINT: n ≥1.

Y - ARRAY OF REAL

EXIT: Result vector y.
CONSTRAINT: Must contain n× incy elements.
CONSTRAINT: Must not overlap with array x.

INCY - INTEGER

ENTRY: Stride for the vector y.
CONSTRAINT: incy̸= 0.
BEHAVIOR: A negative stride will traverse the array in reverse.

X - ARRAY OF REAL

ENTRY: Input vector x.
CONSTRAINT: Must contain n× incx elements.
CONSTRAINT: Must not overlap with array y.

INCX - INTEGER

ENTRY: Stride for the vector x.
CONSTRAINT: incx̸= 0.
BEHAVIOR: A negative stride will traverse the array in reverse.