void Deriv(const InputType& x, OutputType& y) { y = x; for (size_t i = 0; i < x.n_elem; i++) y(i) = Deriv(x(i)); }
void Backward(const arma::Cube<eT>& input, const arma::Mat<eT>& gy, arma::Cube<eT>& g) { // Generate a cube using the backpropagated error matrix. arma::Cube<eT> mappedError = arma::zeros<arma::cube>(input.n_rows, input.n_cols, input.n_slices); for (size_t s = 0, j = 0; s < mappedError.n_slices; s+= gy.n_cols, j++) { for (size_t i = 0; i < gy.n_cols; i++) { arma::Col<eT> temp = gy.col(i).subvec( j * input.n_rows * input.n_cols, (j + 1) * input.n_rows * input.n_cols - 1); mappedError.slice(s + i) = arma::Mat<eT>(temp.memptr(), input.n_rows, input.n_cols); } } arma::Cube<eT> derivative; Deriv(input, derivative); g = mappedError % derivative; }
void Backward(const DataType& input, const DataType& gy, DataType& g) { DataType derivative; Deriv(input, derivative); g = gy % derivative; }
Rigid3dTypes::Deriv DistanceLMConstraint<Rigid3dTypes>::getDirection(const Edge &e, const VecCoord &x1, const VecCoord &x2) const { Vector3 V12=(x2[e[1]].getCenter() - x1[e[0]].getCenter()); V12.normalize(); return Deriv(V12, Vector3()); }