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.

config.py 3.4 kB

5 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # Copyright 2020 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """ config. """
  15. import argparse
  16. def argparse_init():
  17. """
  18. argparse_init
  19. """
  20. parser = argparse.ArgumentParser(description='WideDeep')
  21. parser.add_argument("--data_path", type=str, default="./test_raw_data/")
  22. parser.add_argument("--epochs", type=int, default=15)
  23. parser.add_argument("--batch_size", type=int, default=10000)
  24. parser.add_argument("--eval_batch_size", type=int, default=15)
  25. parser.add_argument("--field_size", type=int, default=39)
  26. parser.add_argument("--vocab_size", type=int, default=184965)
  27. parser.add_argument("--emb_dim", type=int, default=80)
  28. parser.add_argument("--deep_layer_dim", type=int, nargs='+', default=[1024, 512, 256, 128])
  29. parser.add_argument("--deep_layer_act", type=str, default='relu')
  30. parser.add_argument("--keep_prob", type=float, default=1.0)
  31. parser.add_argument("--output_path", type=str, default="./output/")
  32. parser.add_argument("--ckpt_path", type=str, default="./checkpoints/")
  33. parser.add_argument("--eval_file_name", type=str, default="eval.log")
  34. parser.add_argument("--loss_file_name", type=str, default="loss.log")
  35. return parser
  36. class Config_WideDeep():
  37. """
  38. Config_WideDeep
  39. """
  40. def __init__(self):
  41. self.data_path = "./test_raw_data/"
  42. self.epochs = 15
  43. self.batch_size = 10000
  44. self.eval_batch_size = 10000
  45. self.field_size = 39
  46. self.vocab_size = 184965
  47. self.emb_dim = 80
  48. self.deep_layer_dim = [1024, 512, 256, 128]
  49. self.deep_layer_act = 'relu'
  50. self.weight_bias_init = ['normal', 'normal']
  51. self.emb_init = 'normal'
  52. self.init_args = [-0.01, 0.01]
  53. self.dropout_flag = False
  54. self.keep_prob = 1.0
  55. self.l2_coef = 8e-5
  56. self.output_path = "./output"
  57. self.eval_file_name = "eval.log"
  58. self.loss_file_name = "loss.log"
  59. self.ckpt_path = "./checkpoints/"
  60. def argparse_init(self):
  61. """
  62. argparse_init
  63. """
  64. parser = argparse_init()
  65. args, _ = parser.parse_known_args()
  66. self.epochs = args.epochs
  67. self.batch_size = args.batch_size
  68. self.eval_batch_size = args.eval_batch_size
  69. self.field_size = args.field_size
  70. self.vocab_size = args.vocab_size
  71. self.emb_dim = args.emb_dim
  72. self.deep_layer_dim = args.deep_layer_dim
  73. self.deep_layer_act = args.deep_layer_act
  74. self.keep_prob = args.keep_prob
  75. self.weight_bias_init = ['normal', 'normal']
  76. self.emb_init = 'normal'
  77. self.init_args = [-0.01, 0.01]
  78. self.dropout_flag = False
  79. self.l2_coef = 8e-5
  80. self.output_path = args.output_path
  81. self.eval_file_name = args.eval_file_name
  82. self.loss_file_name = args.loss_file_name
  83. self.ckpt_path = args.ckpt_path