-
Notifications
You must be signed in to change notification settings - Fork 29
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
[WIP] New feature extraction mechanism #72
Conversation
I have a first draft of the feature extraction working all the way. You can see the example in My implementation is using a lot of broadcasting. Some stuff is not efficient, like constructing a dictionary all the times. If we only want to keep I decided to use dictionary instead of NamedTuples because it is a bit more flexible in terms of key types. If the ids are integer we cannot do |
else | ||
@assert(a.dir == DIR_RIGHT) | ||
convert(Float64, get(LANEOFFSETRIGHT, scene, roadway, vehicle_index)) | ||
return lane_offset_right(roadway, scene[vehicle_index]) |
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.
I think we could be giving a more informative error message here if a.dir
has an invalid value, such as
if a.dir == DIR_MIDDLE
...
elseif a.dir == DIR_LEFT
...
elseif a.dir == DIR_RIGHT
...
else
throw(ErrorException("invalid direction"))
end
or similar instead of the assertion (a message like assertion a.dir == DIR_RIGHT failed
may be confusing for users).
# feature(actions, veh) | ||
# struct TemporalActionFeature <: AbstractFeature end | ||
# feature(action, veh) | ||
# struct ActionFeature <: AbstractFeature end |
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 already support action features now, out of the box? I think they are expected to occur very soon (in fact, if I want to port my DenseTrafficMerging
repo to the new feature extraction interface, I would already need it).
featuretype(f::Function) | ||
function used for dispatching feature types depending on the method of the feature function | ||
""" | ||
function featuretype(f::Function) |
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.
If users want to add their own new type of feature, will they have to edit the featuretype
function?
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.
No! :D just implement their function with one of the supported method.
The trait is determined at compile time so there should be no overhead.
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.
What I meant is a new FeatureType
, such as ActionFeature
?
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.
oh yes then, you would need to add a check for the new method.
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.
My main concern is that it's not easy right now to add actions to the interface (from the user side), so our callbacks effectively don't support actions
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.
the callbacks do support actions, the feature extraction does not for now.
I think it would require extending the top level function extract_features
to have a list of actions as inputs.
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.
Fair enough we can still use callbacks for collecting action related metrics, that should be good enough - didn't think about that
This PR implements a new feature extraction mechanism and interface.
#70
extract_features
function.DistanceTo(:bob)
,CollisionWith(:alice)
, ...). This is conflicting with the use of symbols and needs to be discussed.Most of the features from the previous version are implemented