Skip to content

popfido/NeuralMF-Pytorch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NeuralMF-Pytorch

This is an Implementation of paper Neural Collaborate Filtering use Personal Pytorch Template.

It is inspired by Meitu DL-Project-Template but using pytorch instead of tensorflow for pytorch researchers/developers.

It also used a personalized version of torchsample which contains series of Keras API for pytorch. You can find it in my personal directory: Torchsample.

By H. L. Wang

Usage

git clone https://github.com/popfido/DL-Project-Template

Build and activate of virtualenv

# Through Virtualenv
virtualenv venv
source venv/bin/activate

# Or Conda
conda create -n venv

Install Python Dependecy

git clone https://github.com/popfido/torchsample

cd torchsample && python setup.py install

pip install -r requirements.txt

Noted that the requirement version of torchsample is 0.2.0, which is a special version maintained by myself for the reason that the official torchsample maintainer has been out of maintain for half an year.

# use get_movielen.py to get movielen dataset for testing
python data/get_movielen.py

# See help for main script usage
python main.py help

Directory Structure

├── bases
│   ├── BaseDataLoader.py               - BaseDataLoader Class
│   ├── BaseConfig.py                   - BaseConfig Class
│   └── BaseModule.py                   - BaseModule Class
├── configs                             - Config Directory
│   ├── NeuralMFConfig.py               - Config.py file
│   └── neuralMF_config.json            - Json format config file
├── data_loaders                        - DataLoader Class Directory
│   ├── __init__.py
│   └── cf_dl.py                        - CF Dataset DataLoader
├── main.py                             - Main Class
├── models                              - Module Directory
│   ├── __init__.py
│   ├── NeuralMF.py                     - Neural Collaborate Matrix Factorization Module
│   ├── MultilayerPerceptron.py         - Multi-Layer Perceptron Module
│   ├── GeneralizedMF.py                - Generalized Matrix Factorization Module
│   └── ModuleUtils.py                  - Utils Module for other Module
├── requirements.txt                    - Dependencies
└── utils                               - Utils Directory
    ├── __init__.py
    ├── config_utils.py                 - Config Utils
    ├── np_utils.py                     - NumPy Utils
    └── utils.py                        - Other Utils

Main Component

DataLoader

How to:

  1. Create your own DataLoade with BaseDataLoader.
  2. Implement get_train_data() and get_test_data() Methods;

Module

How to:

  1. Create your own Network Module with BaseModule (also );
  2. Implement __init__() and forward() to create the NN strucure you want;

Config

Define all parameter during training by JSON or from commandline.