jostyposty
commited on
Commit
•
ec9247d
1
Parent(s):
8f85198
docs: Added how to load the model
Browse files
README.md
CHANGED
@@ -26,10 +26,26 @@ model-index:
|
|
26 |
## Usage
|
27 |
|
28 |
```python
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
```
|
35 |
|
|
|
26 |
## Usage
|
27 |
|
28 |
```python
|
29 |
+
import gymnasium as gym
|
30 |
+
import pickle5 as pickle
|
31 |
+
from huggingface_sb3 import load_from_hub
|
32 |
+
from hf_course_code import evaluate_agent # Code from the course https://huggingface.co/learn/deep-rl-course/unit2/hands-on#the-evaluation-method-
|
33 |
|
34 |
+
model_pickle = load_from_hub(repo_id="jostyposty/drl-course-unit-02-taxi-v3", filename="q-learning.pkl")
|
35 |
|
36 |
+
with open(model_pickle, "rb") as f:
|
37 |
+
model = pickle.load(f)
|
38 |
+
|
39 |
+
env = gym.make(model["env_id"])
|
40 |
+
|
41 |
+
mean_reward, std_reward = evaluate_agent(
|
42 |
+
env,
|
43 |
+
model["max_steps"],
|
44 |
+
model["n_eval_episodes"],
|
45 |
+
model["qtable"],
|
46 |
+
model["eval_seed"],
|
47 |
+
)
|
48 |
+
result = mean_reward - std_reward
|
49 |
+
print(f"Result={result:.2f}, Mean_reward={mean_reward:.2f} +/- {std_reward:.2f}")
|
50 |
```
|
51 |
|