Douzero_Resnet/evaluate.py

108 lines
4.2 KiB
Python
Raw Normal View History

2021-12-08 17:16:27 +08:00
import os
2021-09-07 16:38:34 +08:00
import argparse
from douzero.evaluation.simulation import evaluate
2021-12-08 17:16:27 +08:00
2021-12-12 16:49:54 +08:00
def make_evaluate(args, vs_config):
landlord_config = vs_config['landlord']
farmer_config = vs_config['farmer']
if landlord_config['prefix'] == 'random':
args.landlord = 'random'
2021-12-12 16:49:54 +08:00
else:
args.landlord = '%s/%s_landlord_%i.ckpt' % (
landlord_config['folder'], landlord_config['prefix'], landlord_config['frame']
)
if farmer_config['prefix'] == 'random':
args.landlord_up = 'random'
args.landlord_front = 'random'
args.landlord_down = 'random'
2021-12-12 16:49:54 +08:00
else:
args.landlord_up = '%s/%s_landlord_up_%i.ckpt' % (
farmer_config['folder'], farmer_config['prefix'], farmer_config['frame']
)
args.landlord_front = '%s/%s_landlord_front_%i.ckpt' % (
farmer_config['folder'], farmer_config['prefix'], farmer_config['frame']
)
args.landlord_down = '%s/%s_landlord_down_%i.ckpt' % (
farmer_config['folder'], farmer_config['prefix'], farmer_config['frame']
)
print('%s %i\tvs\t%s %i' % (
landlord_config['prefix'], landlord_config['frame'], farmer_config['prefix'], farmer_config['frame']))
2021-12-08 17:16:27 +08:00
evaluate(args.landlord,
args.landlord_up,
2021-12-11 20:07:41 +08:00
args.landlord_front,
2021-12-08 17:16:27 +08:00
args.landlord_down,
args.eval_data,
args.num_workers,
args.output,
args.bid,
args.title)
2021-09-07 16:38:34 +08:00
if __name__ == '__main__':
parser = argparse.ArgumentParser(
2021-12-08 17:16:27 +08:00
'Dou Dizhu Evaluation')
2021-09-07 16:38:34 +08:00
parser.add_argument('--landlord', type=str,
2021-12-08 17:16:27 +08:00
default='baselines/douzero_12/landlord_weights_39762328900.ckpt')
2021-09-07 16:38:34 +08:00
parser.add_argument('--landlord_up', type=str,
2021-12-08 17:16:27 +08:00
default='baselines/douzero_12/landlord_up_weights_39762328900.ckpt')
2021-12-05 12:03:30 +08:00
parser.add_argument('--landlord_front', type=str,
2021-12-08 17:16:27 +08:00
default='baselines/douzero_12/landlord_front_weights_39762328900.ckpt')
2021-09-07 16:38:34 +08:00
parser.add_argument('--landlord_down', type=str,
2021-12-08 17:16:27 +08:00
default='baselines/douzero_12/landlord_down_weights_39762328900.ckpt')
2021-09-07 16:38:34 +08:00
parser.add_argument('--eval_data', type=str,
2021-12-08 17:16:27 +08:00
default='eval_data_200.pkl')
2021-12-12 16:49:54 +08:00
parser.add_argument('--num_workers', type=int, default=3)
2021-09-07 16:38:34 +08:00
parser.add_argument('--gpu_device', type=str, default='0')
parser.add_argument('--output', type=bool, default=True)
parser.add_argument('--bid', type=bool, default=True)
parser.add_argument('--title', type=str, default='New')
args = parser.parse_args()
args.output = True
# args.output = False
2021-09-07 16:38:34 +08:00
args.bid = False
if args.output or args.bid:
args.num_workers = 1
2021-12-08 17:16:27 +08:00
2021-09-07 16:38:34 +08:00
os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'
os.environ["CUDA_VISIBLE_DEVICES"] = args.gpu_device
2021-12-08 17:16:27 +08:00
eval_list = [
2021-12-12 16:49:54 +08:00
# {
# 'landlord': {'folder': 'baselines', 'prefix': 'legacy_general', 'frame': 143539200},
# 'farmer': {'folder': 'baselines', 'prefix': 'legacy_general', 'frame': 143539200},
# 'two_way': False
2021-12-12 16:49:54 +08:00
# },
{
'farmer': { 'folder': 'baselines', 'prefix': 'legacy_general', 'frame': 143539200},
'landlord': { 'folder': 'baselines', 'prefix': 'resnet', 'frame': 23358800},
2021-12-12 16:49:54 +08:00
'two_way': True
},
# {
# 'landlord': {'folder': 'baselines', 'prefix': 'resnet', 'frame': 11534400},
# 'farmer': {'folder': 'baselines', 'prefix': 'resnet', 'frame': 11534400},
# 'two_way': False
# },
# {
# 'landlord': {'folder': 'baselines', 'prefix': 'legacy_resnet', 'frame': 11754400},
# 'farmer': {'folder': 'baselines', 'prefix': 'legacy_resnet', 'frame': 11754400},
# 'two_way': False
# },
# {
# 'landlord': {'folder': 'baselines', 'prefix': 'legacy_resnet', 'frame': 11754400},
# 'farmer': {'folder': 'baselines', 'prefix': 'resnet', 'frame': 11534400},
# 'two_way': True
# },
2021-12-08 17:16:27 +08:00
]
for vs in reversed(eval_list):
2021-12-12 16:49:54 +08:00
make_evaluate(args, vs)
if vs['two_way']:
vs['landlord_bak'] = vs['landlord']
vs['landlord'] = vs['farmer']
vs['farmer'] = vs['landlord_bak']
make_evaluate(args, vs)