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 1.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. # ============================================================================
  15. """
  16. network config setting, will be used in train.py
  17. """
  18. from easydict import EasyDict as edict
  19. import mindspore.common.dtype as mstype
  20. from mindspore.model_zoo.Bert_NEZHA import BertConfig
  21. bert_train_cfg = edict({
  22. 'epoch_size': 10,
  23. 'num_warmup_steps': 0,
  24. 'start_learning_rate': 1e-4,
  25. 'end_learning_rate': 0.0,
  26. 'decay_steps': 1000,
  27. 'power': 10.0,
  28. 'save_checkpoint_steps': 2000,
  29. 'keep_checkpoint_max': 10,
  30. 'checkpoint_prefix': "checkpoint_bert",
  31. # please add your own dataset path
  32. 'DATA_DIR': "/your/path/examples.tfrecord",
  33. # please add your own dataset schema path
  34. 'SCHEMA_DIR': "/your/path/datasetSchema.json"
  35. })
  36. bert_net_cfg = BertConfig(
  37. batch_size=16,
  38. seq_length=128,
  39. vocab_size=21136,
  40. hidden_size=1024,
  41. num_hidden_layers=24,
  42. num_attention_heads=16,
  43. intermediate_size=4096,
  44. hidden_act="gelu",
  45. hidden_dropout_prob=0.0,
  46. attention_probs_dropout_prob=0.0,
  47. max_position_embeddings=512,
  48. type_vocab_size=2,
  49. initializer_range=0.02,
  50. use_relative_positions=True,
  51. input_mask_from_dataset=True,
  52. token_type_ids_from_dataset=True,
  53. dtype=mstype.float32,
  54. compute_type=mstype.float16,
  55. )