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

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