Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,6 +55,19 @@ def compute_metrics(eval_pred):
|
|
| 55 |
#Before passing your predictions to compute, you need to convert the predictions to logits (remember all Transformers models return logits):
|
| 56 |
return metric.compute(predictions=predictions, references=labels)
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
###################################################################################
|
| 60 |
###################################################################################
|
|
@@ -130,7 +143,9 @@ training_args = TrainingArguments(
|
|
| 130 |
overwrite_output_dir = 'True',
|
| 131 |
per_device_train_batch_size=batch_size, #batch_size = 2 for full training
|
| 132 |
per_device_eval_batch_size=batch_size,
|
| 133 |
-
evaluation_strategy = "
|
|
|
|
|
|
|
| 134 |
learning_rate=2e-5,
|
| 135 |
weight_decay=0.01,
|
| 136 |
save_total_limit = 2,
|
|
@@ -191,6 +206,7 @@ print("done")
|
|
| 191 |
#######################################
|
| 192 |
# Load model
|
| 193 |
print("load model_neu")
|
|
|
|
| 194 |
model_name_neu = "alexkueck/test-tis-1"
|
| 195 |
#model_neu = trainer.load("test-tis-1")
|
| 196 |
|
|
|
|
| 55 |
#Before passing your predictions to compute, you need to convert the predictions to logits (remember all Transformers models return logits):
|
| 56 |
return metric.compute(predictions=predictions, references=labels)
|
| 57 |
|
| 58 |
+
#oder mit allen Metriken
|
| 59 |
+
def compute_metrics_alle(eval_pred):
|
| 60 |
+
metrics = ["accuracy", "recall", "precision", "f1"] #List of metrics to return
|
| 61 |
+
metric={}
|
| 62 |
+
for met in metrics:
|
| 63 |
+
metric[met] = load_metric(met)
|
| 64 |
+
logits, labels = eval_pred
|
| 65 |
+
predictions = np.argmax(logits, axis=-1)
|
| 66 |
+
metric_res={}
|
| 67 |
+
for met in metrics:
|
| 68 |
+
metric_res[met]=metric[met].compute(predictions=predictions, references=labels)[met]
|
| 69 |
+
return metric_res
|
| 70 |
+
|
| 71 |
|
| 72 |
###################################################################################
|
| 73 |
###################################################################################
|
|
|
|
| 143 |
overwrite_output_dir = 'True',
|
| 144 |
per_device_train_batch_size=batch_size, #batch_size = 2 for full training
|
| 145 |
per_device_eval_batch_size=batch_size,
|
| 146 |
+
evaluation_strategy = "steps", #oder
|
| 147 |
+
logging_strategy="steps", #oder epoch
|
| 148 |
+
logging_steps=10,
|
| 149 |
learning_rate=2e-5,
|
| 150 |
weight_decay=0.01,
|
| 151 |
save_total_limit = 2,
|
|
|
|
| 206 |
#######################################
|
| 207 |
# Load model
|
| 208 |
print("load model_neu")
|
| 209 |
+
login(token=os.environ["HF_ACCESS_TOKEN"])
|
| 210 |
model_name_neu = "alexkueck/test-tis-1"
|
| 211 |
#model_neu = trainer.load("test-tis-1")
|
| 212 |
|