making general-purpose metric function

This commit is contained in:
Arec
2021-07-20 07:05:09 -07:00
parent 226a427436
commit 1a74fa5237
2 changed files with 51 additions and 6 deletions

47
src/metrics.py Normal file
View File

@@ -0,0 +1,47 @@
import torch
import pickle
import numpy as np
import intersim.collisions
def metrics(filestr: str, test_dataset, policy):
"""
Calculate metrics using a) base filestring to a simulation, and b) the test dataset and learned policy
Args:
filestr (str): base string to outputs of a simulation
test_dataset: a dataset held for testing
policy: policy
"""
# compute metrics using either
# a) simulation files that were saved under the trained policy with prefix 'policy'
# b) applying the policy to observations in the test dataset
# load trajectory
# count collisions (from function in intersim.collisions)
# calculate average velocity
# calculate divergence between velocity distributions
# calcuate divergence between acceleration distributions
pass
def average_velocity(x):
"""
"""
pass
def divergence(p, q, type='kl')
"""
Calculate a divergence between p and q
Args:
p (torch.tensor): (n) samples from p
q (torch.tensor): (n) samples from q
Returns:
d (float): approximate divergence
"""
pass