Github user njayaram2 commented on a diff in the pull request: https://github.com/apache/madlib/pull/243#discussion_r175948750 --- Diff: src/modules/convex/task/mlp.hpp --- @@ -111,6 +117,57 @@ class MLP { template <class Model, class Tuple> double MLP<Model, Tuple>::lambda = 0; +template <class Model, class Tuple> +double +MLP<Model, Tuple>::getLossAndUpdateModel( + model_type &model, + const Matrix &x_batch, + const Matrix &y_true_batch, + const double &stepsize) { + + uint16_t N = model.u.size(); // assuming nu. of layers >= 1 + size_t n = x_batch.rows(); + size_t i, k; + double total_loss = 0.; + + // gradient added over the batch + std::vector<Matrix> total_gradient_per_layer(N); + for (k=0; k < N; ++k) + total_gradient_per_layer[k] = Matrix::Zero(model.u[k].rows(), + model.u[k].cols()); + + for (i=0; i < n; i++){ + ColumnVector x = x_batch.row(i); + ColumnVector y_true = y_true_batch.row(i); + + std::vector<ColumnVector> net, o, delta; + feedForward(model, x, net, o); --- End diff -- We will have to change the design docs too for that. Apparently, the notation used here is supposed to be in sync with the design doc.
---