MCPcopy Create free account
hub / github.com/SpecterOps/DeepPass2 / evaluate_during_training

Function evaluate_during_training

utils/trainingEvaluator.py:346–380  ·  view source on GitHub ↗

Convenience function to call from training loop. Args: model: The model being trained tokenizer: The tokenizer test_data: Test dataset or path to test data device: Device to run evaluation on save_dir: Directory to save results epoch: Cur

(model, tokenizer, test_data, device="cpu", 
                           save_dir="./evaluation_results", epoch=None)

Source from the content-addressed store, hash-verified

344
345# Convenience function to use in training loop
346def evaluate_during_training(model, tokenizer, test_data, device="cpu",
347 save_dir="./evaluation_results", epoch=None):
348 """
349 Convenience function to call from training loop.
350
351 Args:
352 model: The model being trained
353 tokenizer: The tokenizer
354 test_data: Test dataset or path to test data
355 device: Device to run evaluation on
356 save_dir: Directory to save results
357 epoch: Current epoch number (optional, for naming)
358
359 Returns:
360 dict: Evaluation metrics
361 """
362 # Create evaluator
363 if epoch is not None:
364 save_dir = f"{save_dir}/epoch_{epoch}"
365
366 evaluator = ModelEvaluator(save_dir=save_dir)
367
368 # Run evaluation
369 metrics = evaluator.evaluate_model(
370 model=model,
371 tokenizer=tokenizer,
372 test_data=test_data,
373 device=device,
374 batch_size=8,
375 save_results=True,
376 plot_confusion_matrix=True,
377 analyze_errors=True
378 )
379
380 return metrics
381
382
383# Example usage in training script

Callers 1

Calls 2

evaluate_modelMethod · 0.95
ModelEvaluatorClass · 0.85

Tested by

no test coverage detected