I'm trying to implement a Normalizer within Eigen.
The functionality it tries to achieve is as follows:
Xnorm = (X - np.mean(X, axis=0))/(np.std(X, axis=0))
(equivalent numpy)
In the main normalization step I have a function as follows:
typedef Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
matrix_eig;
typedef Eigen::Matrix<float, Eigen::Dynamic, Eigen::RowMajor> vector_eig;
matrix_eig Normalizer::Transform(const matrix_eig &X) {
// mean_ and std_ are vector_eig types
matrix_eig centered = X.rowwise() - mean_.transpose();
// Below line doesnt work since '/' is not allowed for matrices
return centered.rowwise()/std_;
}
My question is how exactly do I do something like centered.rowwise().array()
?
centered.rowwise()/std_
? As far as I know, mathematics does not have a standard way to divide one matrix by another, so I don't see what the intent is. – JaMiTXnorm = (X - np.mean(X, axis=0))/(np.std(X, axis=0))
is the equivalent numpy operation. – tangy