You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 4.6 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. Recommendation Model
  2. ## Overview
  3. This is an implementation of WideDeep as described in the [Wide & Deep Learning for Recommender System](https://arxiv.org/pdf/1606.07792.pdf) paper.
  4. WideDeep model jointly trained wide linear models and deep neural network, which combined the benefits of memorization and generalization for recommender systems.
  5. ## Dataset
  6. The Criteo datasets are used for model training and evaluation.
  7. ## Running Code
  8. ### Code Structure
  9. The entire code structure is as following:
  10. ```
  11. |--- wide_and_deep/
  12. train_and_eval.py "Entrance of Wide&Deep model training and evaluation"
  13. eval.py "Entrance of Wide&Deep model evaluation"
  14. train.py "Entrance of Wide&Deep model training"
  15. train_and_eval_multinpu.py "Entrance of Wide&Deep model data parallel training and evaluation"
  16. train_and_eval_auto_parallel.py
  17. |--- src/ "Entrance of training and evaluation"
  18. config.py "Parameters configuration"
  19. dataset.py "Dataset loader class"
  20. process_data.py "Process dataset"
  21. preprocess_data.py "Pre_process dataset"
  22. wide_and_deep.py "Model structure"
  23. callbacks.py "Callback class for training and evaluation"
  24. metrics.py "Metric class"
  25. |--- script/ "Run shell dir"
  26. run_multinpu_train.sh "Run data parallel"
  27. run_auto_parallel_train.sh "Run auto parallel"
  28. ```
  29. ### Train and evaluate model
  30. To train and evaluate the model, command as follows:
  31. ```
  32. python train_and_eval.py
  33. ```
  34. Arguments:
  35. * `--data_path`: This should be set to the same directory given to the data_download's data_dir argument.
  36. * `--epochs`: Total train epochs.
  37. * `--batch_size`: Training batch size.
  38. * `--eval_batch_size`: Eval batch size.
  39. * `--field_size`: The number of features.
  40. * `--vocab_size`: The total features of dataset.
  41. * `--emb_dim`: The dense embedding dimension of sparse feature.
  42. * `--deep_layers_dim`: The dimension of all deep layers.
  43. * `--deep_layers_act`: The activation of all deep layers.
  44. * `--dropout_flag`: Whether do dropout.
  45. * `--keep_prob`: The rate to keep in dropout layer.
  46. * `--ckpt_path`:The location of the checkpoint file.
  47. * `--eval_file_name` : Eval output file.
  48. * `--loss_file_name` : Loss output file.
  49. To train the model in one device, command as follows:
  50. ```
  51. python train.py
  52. ```
  53. Arguments:
  54. * `--data_path`: This should be set to the same directory given to the data_download's data_dir argument.
  55. * `--epochs`: Total train epochs.
  56. * `--batch_size`: Training batch size.
  57. * `--eval_batch_size`: Eval batch size.
  58. * `--field_size`: The number of features.
  59. * `--vocab_size`: The total features of dataset.
  60. * `--emb_dim`: The dense embedding dimension of sparse feature.
  61. * `--deep_layers_dim`: The dimension of all deep layers.
  62. * `--deep_layers_act`: The activation of all deep layers.
  63. * `--dropout_flag`: Whether do dropout.
  64. * `--keep_prob`: The rate to keep in dropout layer.
  65. * `--ckpt_path`:The location of the checkpoint file.
  66. * `--eval_file_name` : Eval output file.
  67. * `--loss_file_name` : Loss output file.
  68. To train the model in distributed, command as follows:
  69. ```
  70. # configure environment path before training
  71. bash run_multinpu_train.sh RANK_SIZE EPOCHS DATASET RANK_TABLE_FILE
  72. ```
  73. ```
  74. # configure environment path before training
  75. bash run_auto_parallel_train.sh RANK_SIZE EPOCHS DATASET RANK_TABLE_FILE
  76. ```
  77. To evaluate the model, command as follows:
  78. ```
  79. python eval.py
  80. ```
  81. Arguments:
  82. * `--data_path`: This should be set to the same directory given to the data_download's data_dir argument.
  83. * `--epochs`: Total train epochs.
  84. * `--batch_size`: Training batch size.
  85. * `--eval_batch_size`: Eval batch size.
  86. * `--field_size`: The number of features.
  87. * `--vocab_size`: The total features of dataset.
  88. * `--emb_dim`: The dense embedding dimension of sparse feature.
  89. * `--deep_layers_dim`: The dimension of all deep layers.
  90. * `--deep_layers_act`: The activation of all deep layers.
  91. * `--keep_prob`: The rate to keep in dropout layer.
  92. * `--ckpt_path`:The location of the checkpoint file.
  93. * `--eval_file_name` : Eval output file.
  94. * `--loss_file_name` : Loss output file.
  95. There are other arguments about models and training process. Use the `--help` or `-h` flag to get a full list of possible arguments with detailed descriptions.