-
Notifications
You must be signed in to change notification settings - Fork 55
[WIP] VerifAI Dynamic Sampling #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
src/verifai/features/features.py
Outdated
| if length is None: | ||
| domain.flattenOnto(value, flattened) | ||
| else: | ||
| fixedDomain = feature.fixedDomains(self.timeBound)[length] | ||
| fixedDomain.flattenOnto(value, flattened) | ||
| if fixedDimension: | ||
| sizePerElt = domain.flattenedDimension | ||
| needed = (feature.maxLength - length) * sizePerElt | ||
| for i in range(needed): | ||
| flattened.append(None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we pull this code out into a helper function (can be local, doesn't need to be a method on the class) and use it in the loop for static features too? Most of the code is identical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(We can leave this to later, it's not that important)
| dim += 1 # Timesteps | ||
| for feature in self.features: | ||
| domain = feature.domain | ||
| timeMult = self.timeBound if isinstance(feature, TimeSeriesFeature) else 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A thought probably best left for later: maybe we should move all the flattening logic into new Feature._flatten and Feature._flattenedDimension methods. Then this kind of case split could be handled by overrides in TimeSeriesFeature instead of needing to have special cases here.
dfremont
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall. Details are in comments above, but my main suggestion is to try to preserve the simple way to access features from the sampled point (point.myFeature instead of point.staticSample.myFeature). If we can do that, then most of the changes you had to make to the existing tests shouldn't be necessary.
Co-authored-by: Daniel Fremont <dfremont@ucsc.edu>
Adds dynamic sampling to VerifAI.
Merge with BerkeleyLearnVerify/Scenic#417