LibRecommender icon indicating copy to clipboard operation
LibRecommender copied to clipboard

reg parameter example

Open yustiks opened this issue 4 years ago • 3 comments

Hello! I am trying to implement SVD++, and I have an issue. I would like to add parameter reg (as regularization penalty), but I couldn't find any examples. Would be great if there are some!

yustiks avatar May 12 '21 19:05 yustiks

Just set the reg parameter:

svdpp = SVDpp(...,  reg=0.1)

massquantity avatar May 13 '21 13:05 massquantity

@massquantity thank you for fast reply! is it possible to use different regularization parameters for different values (Pi, Qu, bu, bi, yj)?

yustiks avatar May 13 '21 14:05 yustiks

In that case you can change the source code in LibRecommender/libreco/algorithms/svdpp.py , starting from line 79:

        self.bu_var = tf.get_variable(name="bu_var", shape=[self.n_users],
                                      initializer=tf_zeros,
                                      regularizer=self.reg)
        self.bi_var = tf.get_variable(name="bi_var", shape=[self.n_items],
                                      initializer=tf_zeros,
                                      regularizer=self.reg)
        self.pu_var = tf.get_variable(name="pu_var",
                                      shape=[self.n_users, self.embed_size],
                                      initializer=tf_truncated_normal(
                                          0.0, 0.03),
                                      regularizer=self.reg)
        self.qi_var = tf.get_variable(name="qi_var",
                                      shape=[self.n_items, self.embed_size],
                                      initializer=tf_truncated_normal(
                                          0.0, 0.03),
                                      regularizer=self.reg)

        yj_var = tf.get_variable(name="yj_var",
                                 shape=[self.n_items, self.embed_size],
                                 initializer=tf_truncated_normal(0.0, 0.03),
                                 regularizer=self.reg)

Change all the regularizer=self.reg to the value you want.

massquantity avatar May 13 '21 18:05 massquantity