Skip to content

Commit c4525c1

Browse files
committed
fix f1 score
1 parent c13a057 commit c4525c1

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

config/config_regression.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def __SELF_MM(self):
9696
'need_normalized': False,
9797
'use_bert': True,
9898
'use_finetune': True,
99-
'save_labels': True,
99+
'save_labels': False,
100100
'early_stop': 8,
101101
'update_epochs': 4
102102
},
@@ -174,12 +174,12 @@ def __SELF_MM(self):
174174
# the batch_size of each epoch is update_epochs * batch_size
175175
'batch_size': 32,
176176
'learning_rate_bert': 5e-5,
177-
'learning_rate_audio': 0.005,
178-
'learning_rate_video': 0.001,
179-
'learning_rate_other': 0.001,
180-
'weight_decay_bert': 0.01,
181-
'weight_decay_audio': 0.0,
182-
'weight_decay_video': 0.0,
177+
'learning_rate_audio': 5e-3,
178+
'learning_rate_video': 5e-3,
179+
'learning_rate_other': 1e-3,
180+
'weight_decay_bert': 0.001,
181+
'weight_decay_audio': 0.01,
182+
'weight_decay_video': 0.01,
183183
'weight_decay_other': 0.001,
184184
# feature subNets
185185
'a_lstm_hidden_size': 16,
@@ -195,12 +195,12 @@ def __SELF_MM(self):
195195
# post feature
196196
'post_fusion_dim': 128,
197197
'post_text_dim':64,
198-
'post_audio_dim': 32,
199-
'post_video_dim': 16,
200-
'post_fusion_dropout': 0.1,
198+
'post_audio_dim': 16,
199+
'post_video_dim': 32,
200+
'post_fusion_dropout': 0.0,
201201
'post_text_dropout': 0.1,
202-
'post_audio_dropout': 0.0,
203-
'post_video_dropout': 0.1,
202+
'post_audio_dropout': 0.1,
203+
'post_video_dropout': 0.0,
204204
# res
205205
'H': 1.0
206206
},

utils/metricsTop.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __eval_mosi_classification(self, y_pred, y_true):
3535
# three classes
3636
y_pred_3 = np.argmax(y_pred, axis=1)
3737
Mult_acc_3 = accuracy_score(y_pred_3, y_true)
38-
F1_score_3 = f1_score(y_pred_3, y_true, average='weighted')
38+
F1_score_3 = f1_score(y_true, y_pred_3, average='weighted')
3939
# two classes
4040
y_pred = np.array([[v[0], v[2]] for v in y_pred])
4141
# with 0 (<= 0 or > 0)
@@ -45,14 +45,14 @@ def __eval_mosi_classification(self, y_pred, y_true):
4545
y_true_2.append(0 if v <= 1 else 1)
4646
y_true_2 = np.array(y_true_2)
4747
Has0_acc_2 = accuracy_score(y_pred_2, y_true_2)
48-
Has0_F1_score = f1_score(y_pred_2, y_true_2, average='weighted')
48+
Has0_F1_score = f1_score(y_true_2, y_pred_2, average='weighted')
4949
# without 0 (< 0 or > 0)
5050
non_zeros = np.array([i for i, e in enumerate(y_true) if e != 1])
5151
y_pred_2 = y_pred[non_zeros]
5252
y_pred_2 = np.argmax(y_pred_2, axis=1)
5353
y_true_2 = y_true[non_zeros]
5454
Non0_acc_2 = accuracy_score(y_pred_2, y_true_2)
55-
Non0_F1_score = f1_score(y_pred_2, y_true_2, average='weighted')
55+
Non0_F1_score = f1_score(y_true_2, y_pred_2, average='weighted')
5656

5757
eval_results = {
5858
"Has0_acc_2": round(Has0_acc_2, 4),
@@ -103,12 +103,12 @@ def __eval_mosei_regression(self, y_pred, y_true, exclude_zero=False):
103103
non_zeros_binary_preds = (test_preds[non_zeros] > 0)
104104

105105
non_zeros_acc2 = accuracy_score(non_zeros_binary_preds, non_zeros_binary_truth)
106-
non_zeros_f1_score = f1_score(non_zeros_binary_preds, non_zeros_binary_truth, average='weighted')
106+
non_zeros_f1_score = f1_score(non_zeros_binary_truth, non_zeros_binary_preds, average='weighted')
107107

108108
binary_truth = (test_truth >= 0)
109109
binary_preds = (test_preds >= 0)
110110
acc2 = accuracy_score(binary_preds, binary_truth)
111-
f_score = f1_score(binary_preds, binary_truth, average='weighted')
111+
f_score = f1_score(binary_truth, binary_preds, average='weighted')
112112

113113
eval_results = {
114114
"Has0_acc_2": round(acc2, 4),
@@ -164,7 +164,7 @@ def __eval_sims_regression(self, y_pred, y_true):
164164
mult_a2 = self.__multiclass_acc(test_preds_a2, test_truth_a2)
165165
mult_a3 = self.__multiclass_acc(test_preds_a3, test_truth_a3)
166166
mult_a5 = self.__multiclass_acc(test_preds_a5, test_truth_a5)
167-
f_score = f1_score(test_preds_a2, test_truth_a2, average='weighted')
167+
f_score = f1_score(test_truth_a2, test_preds_a2, average='weighted')
168168

169169
eval_results = {
170170
"Mult_acc_2": mult_a2,

0 commit comments

Comments
 (0)