Official implementation of the Fake News Revealer paper
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

config.py 2.1KB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import torch
  2. from transformers import BertTokenizer, BertModel, BertConfig
  3. from data.config import Config
  4. from data.weibo.data_loader import WeiboDatasetLoader
  5. class WeiboConfig(Config):
  6. name = 'weibo'
  7. DatasetLoader = WeiboDatasetLoader
  8. data_path = 'weibo/'
  9. output_path = ''
  10. rumor_image_path = data_path + 'rumor_images/'
  11. nonrumor_image_path = data_path + 'nonrumor_images/'
  12. train_text_path = data_path + 'weibo_train.csv'
  13. validation_text_path = data_path + 'weibo_validation.csv'
  14. test_text_path = data_path + 'weibo_test.csv'
  15. batch_size = 128
  16. epochs = 100
  17. num_workers = 2
  18. head_lr = 1e-03
  19. image_encoder_lr = 1e-02
  20. text_encoder_lr = 1e-05
  21. weight_decay = 0.001
  22. classification_lr = 1e-02
  23. device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
  24. image_model_name = 'vit-base-patch16-224' # 'resnet101'
  25. image_embedding = 768 # 2048
  26. num_img_region = 64 # TODO
  27. text_encoder_model = "bert-base-chinese"
  28. text_tokenizer = "bert-base-chinese"
  29. text_embedding = 768
  30. max_length = 200
  31. pretrained = True
  32. trainable = False
  33. temperature = 1.0
  34. labels = ['real', 'fake']
  35. wanted_accuracy = 0.80
  36. def optuna(self, trial):
  37. self.head_lr = trial.suggest_loguniform('head_lr', 1e-5, 1e-1)
  38. self.image_encoder_lr = trial.suggest_loguniform('image_encoder_lr', 1e-6, 1e-3)
  39. self.text_encoder_lr = trial.suggest_loguniform('text_encoder_lr', 1e-6, 1e-3)
  40. self.classification_lr = trial.suggest_loguniform('classification_lr', 1e-5, 1e-1)
  41. self.head_weight_decay = trial.suggest_loguniform('head_weight_decay', 1e-5, 1e-1)
  42. # self.attention_weight_decay = trial.suggest_loguniform('attention_weight_decay', 1e-5, 1e-1)
  43. self.classification_weight_decay = trial.suggest_loguniform('classification_weight_decay', 1e-5, 1e-1)
  44. self.projection_size = trial.suggest_categorical('projection_size', [256, 128, 64])
  45. # self.hidden_size = trial.suggest_categorical('hidden_size', [256, 128, 64, ])
  46. # self.dropout = trial.suggest_categorical('drop_out', [0.1, 0.3, 0.5, ])