-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.py
More file actions
28 lines (21 loc) · 932 Bytes
/
demo.py
File metadata and controls
28 lines (21 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import json
from pathlib import Path
from src.inference_engine import LatencyDqnOnnxAgent
from src.state_serializer import LatencyStateSerializer
from src.action_interpreter import ActionInterpreter
MODEL_PATH = "model/5g_latency_opt_dqn_model.onnx"
CONFIG_PATH = "model/model_config.json"
INPUT_JSON = "validation241204.json"
def main():
agent = LatencyDqnOnnxAgent(MODEL_PATH, CONFIG_PATH)
serializer = LatencyStateSerializer(CONFIG_PATH)
interpreter = ActionInterpreter(CONFIG_PATH)
data = json.loads(Path(INPUT_JSON).read_text(encoding="utf-8"))
for i, item in enumerate(data[:10]): # stampa i primi 10
obs = serializer.serialize(item) # (1,3,10)
action, q_vals = agent.predict(obs) # action int, q_values (1,3)
print(f"--- 🧪 Sample {i} ---")
print(interpreter.humanify(action, q_values=q_vals))
print()
if __name__ == "__main__":
main()