be426ba9d5f569b5eab685d96bb418d11fbb5474,spotlight/factorization/implicit.py,ImplicitFactorizationModel,fit,#ImplicitFactorizationModel#Any#Any#,186

Before Change


                                                      batch_size=self._batch_size)):

                user_var = Variable(batch_user)
                item_var = Variable(batch_item)
                positive_prediction = self._net(user_var, item_var)

                if self._loss == "adaptive_hinge":
                    negative_prediction = self._get_multiple_negative_predictions(
                        user_var, n=self._num_negative_samples)
                else:
                    negative_prediction = self._get_negative_prediction(user_var)

                self._optimizer.zero_grad()

                loss = self._loss_func(positive_prediction, negative_prediction)
                epoch_loss += loss.data[0]

                loss.backward()
                self._optimizer.step()

After Change


                self._optimizer.zero_grad()

                loss = self._loss_func(positive_prediction, negative_prediction)
                epoch_loss += loss.item()

                loss.backward()
                self._optimizer.step()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: maciejkula/spotlight
Commit Name: be426ba9d5f569b5eab685d96bb418d11fbb5474
Time: 2018-05-20
Author: maciej.kula@gmail.com
File Name: spotlight/factorization/implicit.py
Class Name: ImplicitFactorizationModel
Method Name: fit


Project Name: maciejkula/spotlight
Commit Name: be426ba9d5f569b5eab685d96bb418d11fbb5474
Time: 2018-05-20
Author: maciej.kula@gmail.com
File Name: spotlight/factorization/explicit.py
Class Name: ExplicitFactorizationModel
Method Name: fit


Project Name: maciejkula/spotlight
Commit Name: be426ba9d5f569b5eab685d96bb418d11fbb5474
Time: 2018-05-20
Author: maciej.kula@gmail.com
File Name: spotlight/sequence/implicit.py
Class Name: ImplicitSequenceModel
Method Name: fit