|
TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
|
Abstract base class for featurizing unit attributes in a sparse manner. More...
#include <unitsfeatures.h>
Inherited by cherrypi::UnitFlagsFeaturizer, cherrypi::UnitPresenceFeaturizer, cherrypi::UnitStatFeaturizer, cherrypi::UnitTypeDefoggerFeaturizer, and cherrypi::UnitTypeFeaturizer.
Classes | |
| struct | Data |
Public Types | |
| using | UnitFilter = std::function< bool(Unit *)> |
| using | TensorDest = torch::TensorAccessor< float, 1 > |
Public Member Functions | |
| virtual | ~UnitAttributeFeaturizer ()=default |
| virtual Data | extract (State *state, UnitsInfo::Units const &units, Rect const &boundingBox=Rect()) |
| Extract unit features for a given set of units. More... | |
| Data | extract (State *state, Rect const &boundingBox=Rect()) |
| Extract unit features for all live units. More... | |
| Data | extract (State *state, UnitFilter filter, Rect const &boundingBox=Rect()) |
| Extract unit features for all live units that pass the given filter. More... | |
| FeatureData | toSpatialFeature (Data const &data, SubsampleMethod pooling=SubsampleMethod::Sum) const |
| Embeds the unit attribute data into a spatial feature. More... | |
| void | toSpatialFeature (FeatureData *dest, Data const &data, SubsampleMethod pooling=SubsampleMethod::Sum) const |
| Embeds the unit attribute data into a spatial feature. More... | |
Public Attributes | |
| std::shared_ptr< BaseJitter > | jitter = std::make_shared<NoJitter>() |
| Optional jittering of unit positions. More... | |
| CustomFeatureType | type |
| std::string | name |
| int | numChannels |
Protected Member Functions | |
| virtual void | extractUnit (TensorDest acc, Unit *unit)=0 |
| Reimplement this in actual featurizers. More... | |
Abstract base class for featurizing unit attributes in a sparse manner.
General usage of sub-classes for actual feature extraction boils down to calling extract() with a desired subset of units to featurize. The resulting data is sparse wrt positions, i.e. it contains a tensor of positions for each unit and the accompanying data as defined by a featurizer implementation.
toSpatialFeature() will transform the given data to a FeatureData object, i.e. it will place the feature data at the respective positions.
Optionally, users can set a jittering method that will be accounted for in extract().
| using cherrypi::UnitAttributeFeaturizer::TensorDest = torch::TensorAccessor<float, 1> |
| using cherrypi::UnitAttributeFeaturizer::UnitFilter = std::function<bool(Unit*)> |
|
virtualdefault |
|
virtual |
Extract unit features for a given set of units.
Reimplemented in cherrypi::UnitTypeMDefoggerFeaturizer.
| UnitAttributeFeaturizer::Data cherrypi::UnitAttributeFeaturizer::extract | ( | State * | state, |
| Rect const & | boundingBox = Rect() |
||
| ) |
Extract unit features for all live units.
| UnitAttributeFeaturizer::Data cherrypi::UnitAttributeFeaturizer::extract | ( | State * | state, |
| UnitFilter | filter, | ||
| Rect const & | boundingBox = Rect() |
||
| ) |
Extract unit features for all live units that pass the given filter.
|
protectedpure virtual |
Reimplement this in actual featurizers.
This function is expected to set acc[0], ..., acc[numChannels-1]
Implemented in cherrypi::UnitStatFeaturizer, cherrypi::UnitFlagsFeaturizer, cherrypi::UnitTypeDefoggerFeaturizer, cherrypi::UnitTypeFeaturizer, and cherrypi::UnitPresenceFeaturizer.
| FeatureData cherrypi::UnitAttributeFeaturizer::toSpatialFeature | ( | Data const & | data, |
| SubsampleMethod | pooling = SubsampleMethod::Sum |
||
| ) | const |
Embeds the unit attribute data into a spatial feature.
| void cherrypi::UnitAttributeFeaturizer::toSpatialFeature | ( | FeatureData * | dest, |
| Data const & | data, | ||
| SubsampleMethod | pooling = SubsampleMethod::Sum |
||
| ) | const |
Embeds the unit attribute data into a spatial feature.
This version will re-use the tensor memory of the given feature data instance.
| std::shared_ptr<BaseJitter> cherrypi::UnitAttributeFeaturizer::jitter = std::make_shared<NoJitter>() |
Optional jittering of unit positions.
| std::string cherrypi::UnitAttributeFeaturizer::name |
| int cherrypi::UnitAttributeFeaturizer::numChannels |
| CustomFeatureType cherrypi::UnitAttributeFeaturizer::type |
1.8.11