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.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import torch
  2. from data.config import Config
  3. from data.weibo.data_loader import WeiboDatasetLoader
  4. class WeiboConfig(Config):
  5. name = 'weibo'
  6. DatasetLoader = WeiboDatasetLoader
  7. data_path = '../../../../../media/external_3TB/3TB/ghorbanpoor/weibo/'
  8. # data_path = '/home/faeze/PycharmProjects/fake_news_detection/data/weibo/'
  9. output_path = '../../../../../media/external_10TB/10TB/ghorbanpoor/'
  10. # output_path = ''
  11. rumor_image_path = data_path + 'rumor_images/'
  12. nonrumor_image_path = data_path + 'nonrumor_images/'
  13. train_text_path = data_path + 'weibo_train.csv'
  14. validation_text_path = data_path + 'weibo_train.csv'
  15. test_text_path = data_path + 'weibo_test.csv'
  16. batch_size = 100
  17. epochs = 100
  18. num_workers = 1
  19. head_lr = 0.0085
  20. image_encoder_lr = 1.0e-05
  21. text_encoder_lr = 0.00016
  22. weight_decay = 0.00015
  23. classification_lr = 0.00149
  24. hidden_size = 128
  25. projection_size = 64
  26. dropout = 0.5
  27. device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
  28. image_model_name = '../../../../../media/external_10TB/10TB/ghorbanpoor/vit-base-patch16-224'
  29. image_embedding = 768
  30. text_encoder_model = "../../../../../media/external_10TB/10TB/ghorbanpoor/bert-base-chinese"
  31. # text_encoder_model = "/home/faeze/PycharmProjects/new_fake_news_detectioin/bert/bert-base-uncased"
  32. text_tokenizer = "../../../../../media/external_10TB/10TB/ghorbanpoor/bert-base-chinese"
  33. # text_tokenizer = "/home/faeze/PycharmProjects/new_fake_news_detectioin/bert/bert-base-uncased"
  34. text_embedding = 768
  35. max_length = 200
  36. pretrained = True
  37. trainable = False
  38. temperature = 1.0
  39. labels = ['real', 'fake']
  40. wanted_accuracy = 0.85
  41. def optuna(self, trial):
  42. self.head_lr = trial.suggest_loguniform('head_lr', 1e-5, 1e-1)
  43. self.image_encoder_lr = trial.suggest_loguniform('image_encoder_lr', 1e-6, 1e-3)
  44. self.text_encoder_lr = trial.suggest_loguniform('text_encoder_lr', 1e-6, 1e-3)
  45. self.classification_lr = trial.suggest_loguniform('classification_lr', 1e-5, 1e-1)
  46. self.head_weight_decay = trial.suggest_loguniform('head_weight_decay', 1e-5, 1e-1)
  47. self.classification_weight_decay = trial.suggest_loguniform('classification_weight_decay', 1e-5, 1e-1)
  48. self.projection_size = trial.suggest_categorical('projection_size', [256, 128, 64])
  49. self.hidden_size = trial.suggest_categorical('hidden_size', [256, 128, 64, ])
  50. self.dropout = trial.suggest_categorical('drop_out', [0.1, 0.3, 0.5, ])