Skip to content

Commit 41cc55c

Browse files
committed
First commit with the whole implementation.
1 parent f19b299 commit 41cc55c

25 files changed

+247381
-1
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,7 @@ venv.bak/
102102

103103
# mypy
104104
.mypy_cache/
105+
106+
# IRGAN output
107+
runs/
108+
runs_bak/

IRGAN-SGD-dns-gen.ipynb

+32,000
Large diffs are not rendered by default.

README.md

+49-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,49 @@
1-
# PyTorch-IRGAN
1+
# PyTorch-IRGAN
2+
3+
4+
## Description
5+
6+
This project contains a pytorch version implementation about the item recommendation part of [IRGAN: A Minimax Game for Unifying Generative and Discriminative Information Retrieval Models](https://arxiv.org/abs/1705.10513). The official implementation can be found at https://github.com/geek-ai/irgan. If you have any problems on this implementation, please open an issue.
7+
8+
9+
## Requirements
10+
11+
Please refer to requirements.txt
12+
13+
## Project Structure
14+
15+
.
16+
├── config.py (Configurations about IRGAN and BPR.)
17+
├── data (Data Files)
18+
│   ├── movielens-100k-test.txt
19+
│   └── movielens-100k-train.txt
20+
├── data_utils.py (Utilities about dataset.)
21+
├── evaluation (Evaluation metrics and tools.)
22+
│   ├── __init__.py
23+
│   ├── rank_metrics.py
24+
│   └── rec_evaluator.py
25+
├── exp_notebooks (Notebooks containing experiments for comparison. dns means using pre-trained models with dynamic negative sampling.
26+
│ │ gen means pre-training generator while dis means pre-training discriminator. SGD and Adam are optimizers adopted.)
27+
│   ├── BPR.ipynb
28+
│   ├── IRGAN-Adam-dns-gen-dis.ipynb
29+
│   ├── IRGAN-Adam-dns-gen.ipynb
30+
│   ├── IRGAN-Adam-without-pretrained-model.ipynb
31+
│   ├── IRGAN-dns-gen-Adam-G-SGD-D.ipynb
32+
│   ├── IRGAN-SGD-dns-gen-dis.ipynb
33+
│   ├── IRGAN-SGD-dns-gen-static-negative-sampling.ipynb
34+
│   ├── IRGAN-SGD-without-pretrained-model.ipynb
35+
│   ├── Pretrain-Discriminator-Dynamic-Negative-Sampling-Adam.ipynb
36+
│   ├── Pretrain-Discriminator-Dynamic-Negative-Sampling.ipynb
37+
│   └── Pretrain-Discriminator-Static-Negative-Sampling.ipynb
38+
├── IRGAN-SGD-dns-gen.ipynb(IRGAN with the SGD optimizer and a pre-trained model with dynamic negative sampling for generator.)
39+
├── model.py (Model definition.)
40+
├── pretrained_models (Pre-trained models)
41+
│   ├── pretrained_model_dns.pkl
42+
│   └── pretrained_model_sns.pkl
43+
├── readme.md
44+
45+
## How to run
46+
1. Execute **conda create --name <env_name> --file requirements.txt** to create an virtual environment and install required packages.
47+
2. Run a jupyter notebook server by **jupyter notebook**.
48+
3. Open IRGAN-SGD-dns-gen.ipynb in a browser and run all cells.
49+
The output of loss and other evaluation metrics can be observed with tensorboard.(Other notebooks from the *exp_notebooks* directory can be moved out to its upper-level directory and run).

config.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""Configuration files
2+
3+
"""
4+
5+
class Config():
6+
def __init__(self):
7+
self.epochs = 200
8+
self.epochs_g = 50
9+
self.epochs_d = 100
10+
self.batch_size = 64
11+
self.eta_G = 1e-3 # Learning Rate for generator
12+
self.eta_D = 1e-3 # Learning Rate for discriminator
13+
self.dir_path = "./data/"
14+
self.emb_dim = 5
15+
self.weight_decay = 1e-5
16+
self.weight_decay_g = 1e-5
17+
self.weight_decay_d = 1e-5
18+
self.patience = 300
19+
self.device = "cuda:0"
20+
21+
class BprConfig():
22+
def __init__(self):
23+
self.epochs = 200
24+
self.batch_size = 64
25+
self.eta = 1e-3
26+
self.dir_path = "./data/"
27+
self.emb_dim = 5
28+
self.device = "cuda:0"
29+
self.weight_decay = 1e-5
30+
bpr_config = BprConfig()
31+
irgan_config = Config()

0 commit comments

Comments
 (0)