import torch from train_anomaly_detector import Autoencoder, score_samples checkpoint = torch.load("anomaly_detector.pt", weights_only=True) model = Autoencoder(checkpoint["feature_count"]) model.load_state_dict(checkpoint["model_state"]) samples = torch.tensor( [ [0.05, -0.04, 0.02, 0.01, -0.03, 0.04], [3.10, 2.85, 3.25, 2.95, 3.05, 3.15], ], dtype=torch.float32, ) scores = score_samples(model, samples) threshold = checkpoint["threshold"] print(f"normal_sample_score={scores[0]:.6f}") print(f"suspect_sample_score={scores[1]:.6f}") print(f"threshold={threshold:.6f}") decision = bool(scores[0] < threshold and scores[1] > threshold) print(f"loaded_checkpoint_decision={decision}")