Skip to content

Commit

Permalink
more formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
izhigal committed Jan 26, 2024
1 parent 8b8abed commit b95e141
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions examples/evaluate.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
"""An example of evluating the trained models in RLCard
"""
"""An example of evaluating the trained models in RLCard"""
import os
import argparse

import rlcard
from rlcard.agents import (
DQNAgent,
RandomAgent,
)

from rlcard.utils import (
get_device,
set_seed,
tournament,
)


def load_model(model_path, env=None, position=None, device=None):
if os.path.isfile(model_path): # Torch model
import torch
Expand All @@ -29,14 +26,14 @@ def load_model(model_path, env=None, position=None, device=None):
else: # A model in the model zoo
from rlcard import models
agent = models.load(model_path).agents[position]

return agent

def evaluate(args):

def evaluate(args):
# Check whether gpu is available
device = get_device()

# Seed numpy, torch, random
set_seed(args.seed)

Expand All @@ -54,6 +51,7 @@ def evaluate(args):
for position, reward in enumerate(rewards):
print(position, args.models[position], reward)


if __name__ == '__main__':
parser = argparse.ArgumentParser("Evaluation example in RLCard")
parser.add_argument(
Expand Down Expand Up @@ -99,4 +97,3 @@ def evaluate(args):

os.environ["CUDA_VISIBLE_DEVICES"] = args.cuda
evaluate(args)

0 comments on commit b95e141

Please sign in to comment.