11 Star 55 Fork 20

MindSpore / xai

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 8.65 KB
一键复制 编辑 原始数据 按行查看 历史
TonyNG 提交于 2022-05-13 14:36 . enhance README

Contents

TB-Net Description

TB-Net is a knowledge graph based explainable recommender system.

Paper: Shendi Wang, Haoyang Li, Xiao-Hui Li, Caleb Chen Cao, Lei Chen. Tower Bridge Net (TB-Net): Bidirectional Knowledge Graph Aware Embedding Propagation for Explainable Recommender Systems

Model Architecture

TB-Net constructs subgraphs in knowledge graph based on the interaction between users and items as well as the feature of items, and then calculates paths in the graphs using bidirectional conduction algorithm. Finally we can obtain explainable recommendation results.

Dataset

We provide an example dataset that created from Interaction of users and games and games' feature data of the game platform Steam that are publicly available on Kaggle.

Please refer to Downloading Data Package for the way of obtaining the example dataset and the file format descriptions.

Environment Requirements

Quick Start

Please refer to Using TB-Net for the quick start guide.

Script Description

Script and Sample Code

.
└─tbnet
  ├─README.md
  ├─README_CN.md
  ├─data
  │ └─steam
  │   ├─LICENSE
  │   ├─config.json                 # hyper-parameters and training configuration
  │   ├─src_infer.csv               # source datafile for inference
  │   ├─src_test.csv                # source datafile for evaluation
  │   └─src_train.csv               # source datafile for training
  ├─src
  │ ├─dataset.py                    # dataset loader
  │ ├─embedding.py                  # embedding module
  │ ├─metrics.py                    # model metrics
  │ ├─path_gen.py                   # data preprocessor
  │ ├─recommend.py                  # result aggregator
  │ └─tbnet.py                      # TB-Net architecture
  ├─export.py                       # export MINDIR/AIR script
  ├─preprocess.py                   # data pre-processing script
  ├─eval.py                         # evaluation script
  ├─infer.py                        # inference and explaining script
  └─train.py                        # training script

Script Arguments

  • preprocess.py arguments
--dataset <DATASET>        'steam' dataset is supported currently (default 'steam')
--same_relation            only generate paths that relation1 is same as relation2
  • train.py arguments
--dataset <DATASET>        'steam' dataset is supported currently (default 'steam')
--train_csv <TRAIN_CSV>    the train csv datafile inside the dataset folder (default 'train.csv')
--test_csv <TEST_CSV>      the test csv datafile inside the dataset folder (default 'test.csv')
--epochs <EPOCHS>          number of training epochs (default 20)
--device_id <DEVICE_ID>    device id (default 0)
--run_mode <MODE>          run model in 'GRAPH' mode or 'PYNATIVE' mode (default 'GRAPH')
  • eval.py arguments
--checkpoint_id <CKPT_ID>    the id of the checkpoint(.ckpt) to be used
--dataset <DATASET>          'steam' dataset is supported currently (default 'steam')
--csv <CSV>                  the test csv datafile inside the dataset folder (default 'test.csv')
--device_id <DEVICE_ID>    device id (default 0)
--run_mode <MODE>          run model in 'GRAPH' mode or 'PYNATIVE' mode (default 'GRAPH')
  • infer.py arguments
--checkpoint_id <CKPT_ID>    the id of the checkpoint(.ckpt) to be used
--dataset <DATASET>          'steam' dataset is supported currently (default 'steam')
--csv <CSV>                  the infer csv datafile inside the dataset folder (default 'infer.csv')
--items <ITEMS>              no. of items to be recommended (default 3)
--explanations <EXP>         no. of recommendation reasons to be shown (default 3)
--device_id <DEVICE_ID>      device id (default 0)
--run_mode <MODE>            run model in 'GRAPH' mode or 'PYNATIVE' mode (default 'GRAPH')
  • export.py arguments
--config_path <CFG_PATH>        config (config.json) file path
--checkpoint_path <CKPT_PATH>   checkpoint (.ckpt) file path
--file_name <FILENAME>          export filename
--file_format <FORMAT>          export format 'MINDIR' or 'AIR' (default 'MINDIR')
--device_id <DEVICE_ID>         device id (default 0)
--run_mode <MODE>               run model in 'GRAPH' mode or 'PYNATIVE' mode (default 'GRAPH')

Model Description

Performance

Training Performance

Parameters GPU
Model Version TB-Net
Resource Tesla V100-SXM2-32GB
Uploaded Date 2021-08-01
MindSpore Version 1.3.0
Dataset steam
Training Parameter epoch=20, batch_size=1024, lr=0.001
Optimizer Adam
Loss Function Sigmoid Cross Entropy
Outputs AUC=0.8596, Accuracy=0.7761
Loss 0.57
Speed 1pc: 90ms/step
Total Time 1pc: 297s
Checkpoint for Fine Tuning 104.66M (.ckpt file)

Evaluation Performance

Parameters GPU
Model Version TB-Net
Resource Tesla V100-SXM2-32GB
Uploaded Date 2021-08-01
MindSpore Version 1.3.0
Dataset steam
Batch Size 1024
Outputs AUC=0.8252, Accuracy=0.7503
Total Time 1pc: 5.7s

Inference and Explaining Performance

Parameters GPU
Model Version TB-Net
Resource Tesla V100-SXM2-32GB
Uploaded Date 2021-08-01
MindSpore Version 1.3.0
Dataset steam
Outputs Recommendation Result and Explanation
Total Time 1pc: 3.66s

Description of Random Situation

  • Initialization of embedding matrix in tbnet.py and embedding.py.
Python
1
https://gitee.com/mindspore/xai.git
git@gitee.com:mindspore/xai.git
mindspore
xai
xai
r1.8

搜索帮助

53164aa7 5694891 3bd8fe86 5694891