Git Product home page Git Product logo

Comments (1)

Re-bin avatar Re-bin commented on June 22, 2024

Hi!

Thanks for your interest! The code for sampling positive/negative items can be found in the data_utils/datasets_general_cf.py file, as shown below:

class PairwiseTrnData(data.Dataset):
    def __init__(self, coomat):
    self.rows = coomat.row
    self.cols = coomat.col
    self.dokmat = coomat.todok()
    self.negs = np.zeros(len(self.rows)).astype(np.int32)
    
    def sample_negs(self):
    for i in range(len(self.rows)):
	u = self.rows[i]
	while True:
            iNeg = np.random.randint(configs['data']['item_num'])
            if (u, iNeg) not in self.dokmat:
                break
	self.negs[i] = iNeg
    
    def __len__(self):
    return len(self.rows)
    
    def __getitem__(self, idx):
    return self.rows[idx], self.cols[idx], self.negs[idx]

While it may differ from the sampling strategy used in LightGCN-PyTorch, which employs uniform sampling by first sampling users and then sampling both positive and negative items, SSLRec follows the distribution of the original interactions. This means that we sample negative items for each interaction during training.

Additionally, during training, we employ early stopping to avoid manually tuning the number of training epochs for all methods. This approach has proven effective for the currently implemented methods. However, when dealing with new datasets, the hyperparameters for early stopping (such as the patience) may vary to achieve optimal performance for different methods.

Moreover, several model-agnostic sub-details (models/model_utils.py, models/loss_utils.py), such as InfoNCE loss and regularization loss, are uniformly implemented in our SSLRec for all methods. However, it is important to note that the implementation may differ from other repositories. Each repository has its own unique design and implementation approach. Nonetheless, in all our current experiments, SimGCL consistently outperforms LightGCN in various scenarios and datasets.

Lastly, thank you for testing our framework and for your valuable questions. If you have any ideas to improve SSLRec, please don't hesitate to submit a pull request (PR). We appreciate your contributions to enhance the SSLRec framework : )

Best regards,
Xubin

from sslrec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.