Skip to content

Commit 83abf62

Browse files
committed
Merge branch 'master' of github.com:rexyai/rsparse
2 parents 50f2332 + 66df48a commit 83abf62

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

inst/include/wrmf_implicit.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ T als_implicit(const dMappedCSC& Conf, arma::Mat<T>& X, arma::Mat<T>& Y,
171171
arma::uword p2 = Conf.col_ptrs[i + 1];
172172
// catch situation when some columns in matrix are empty, so p1 becomes equal to p2 or
173173
// greater than number of columns
174-
if (p1 < p2) {
174+
if (with_biases || global_bias || p1 < p2) {
175175
const arma::uvec idx = arma::uvec(&Conf.row_indices[p1], p2 - p1, false, true);
176176
arma::Col<T> confidence =
177177
arma::conv_to<arma::Col<T> >::from(arma::vec(&Conf.values[p1], p2 - p1));
@@ -248,7 +248,9 @@ T als_implicit(const dMappedCSC& Conf, arma::Mat<T>& X, arma::Mat<T>& Y,
248248
Y.unsafe_col(i) = Y_new;
249249
}
250250

251-
if (!global_bias && !with_biases)
251+
if (p1 == p2)
252+
loss += lambda * arma::dot(Y_new, Y_new);
253+
else if (!global_bias && !with_biases)
252254
loss += dot(square(1 - (Y_new.t() * X_nnz)), confidence) +
253255
lambda * arma::dot(Y_new, Y_new);
254256
else if (global_bias && !with_biases)

0 commit comments

Comments
 (0)