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.

finetune_eval_config.py 1.9 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. config settings, will be used in finetune.py
  17. """
  18. from easydict import EasyDict as edict
  19. import mindspore.common.dtype as mstype
  20. from .bert_model import BertConfig
  21. optimizer_cfg = edict({
  22. 'optimizer': 'Lamb',
  23. 'AdamWeightDecayDynamicLR': edict({
  24. 'learning_rate': 2e-5,
  25. 'end_learning_rate': 1e-7,
  26. 'power': 1.0,
  27. 'weight_decay': 1e-5,
  28. 'eps': 1e-6,
  29. }),
  30. 'Lamb': edict({
  31. 'start_learning_rate': 2e-5,
  32. 'end_learning_rate': 1e-7,
  33. 'power': 1.0,
  34. 'weight_decay': 0.01,
  35. 'decay_filter': lambda x: False,
  36. }),
  37. 'Momentum': edict({
  38. 'learning_rate': 2e-5,
  39. 'momentum': 0.9,
  40. }),
  41. })
  42. bert_net_cfg = BertConfig(
  43. batch_size=16,
  44. seq_length=128,
  45. vocab_size=21128,
  46. hidden_size=768,
  47. num_hidden_layers=12,
  48. num_attention_heads=12,
  49. intermediate_size=3072,
  50. hidden_act="gelu",
  51. hidden_dropout_prob=0.1,
  52. attention_probs_dropout_prob=0.1,
  53. max_position_embeddings=512,
  54. type_vocab_size=2,
  55. initializer_range=0.02,
  56. use_relative_positions=False,
  57. input_mask_from_dataset=True,
  58. token_type_ids_from_dataset=True,
  59. dtype=mstype.float32,
  60. compute_type=mstype.float16,
  61. )