SmartEngine  1.6.0
CuriosityModule.h
1 // Copyright (C) Entropy Software LLC - All Rights Reserved
2 
3 #pragma once
4 
5 #include "Agent.h"
6 #include "Context.h"
7 #include "GradientDescentTrainer.h"
8 #include "Resource.h"
9 
10 namespace SmartEngine
11 {
12 
13 #pragma pack(push, 4)
14 struct CuriosityModuleCInfo : public ResourceCInfo
18 {
22  IContext* context = nullptr;
23 
27  IGraph* graph = nullptr;
28 
32  const char** actionNodeNames = nullptr;
33 
38 
44 
48  float rewardMultiplier = 0.01f;
49 
56  float maxIndividualReward = 0.0f;
57 
61  bool normalizeRewards = false;
62 
69  float minThresholdStdDev = 0.0f;
70 
77 
81  int sequenceLength = 1;
82 
87 };
88 #pragma pack(pop)
89 
107 class SMARTENGINE_EXPORT ICuriosityModule : public virtual IObject, public IResource
108 {
109 public:
110  SMARTENGINE_DECLARE_CLASS(ICuriosityModule)
111 
112 
113  virtual void SetRandomWeights() = 0;
116 
122  virtual float GetLoss() = 0;
123 
129  virtual float GetReward() = 0;
130 };
131 
136 
138 extern "C"
139 {
140  SMARTENGINE_EXPORT ObjPtr CuriosityModule_CreateInstance(const CuriosityModuleCInfo& cinfo);
141  SMARTENGINE_EXPORT void CuriosityModule_SetRandomWeights(ObjPtr object);
142  SMARTENGINE_EXPORT float CuriosityModule_GetLoss(ObjPtr object);
143  SMARTENGINE_EXPORT float CuriosityModule_GetReward(ObjPtr object);
144 }
146 
147 } // namespace SmartEngine
SmartEngine::CuriosityModuleCInfo
Data used to construct an ICuriosityModule instance
Definition: CuriosityModule.h:18
SmartEngine::CuriosityModuleCInfo::trainingInfo
GradientDescentTrainingInfo trainingInfo
The parameters used to train the internal curiosity graph.
Definition: CuriosityModule.h:86
SmartEngine::CuriosityModuleCInfo::context
IContext * context
Context the constructed graph will belong to. Only graph nodes of the same context can be connected.
Definition: CuriosityModule.h:22
SmartEngine::CuriosityModuleCInfo::minThresholdStdDev
float minThresholdStdDev
Reward values less than this many standard deviations away from a value of 0.0 will be set to 0....
Definition: CuriosityModule.h:69
SmartEngine::CuriosityModuleCInfo::maxIndividualReward
float maxIndividualReward
The maximum allowed reward for a single observation.
Definition: CuriosityModule.h:56
SmartEngine::CuriosityModuleCInfo::observationFeatureDimension
int observationFeatureDimension
Internally, the observation input is turned into a feature space. This value specifies the dimension ...
Definition: CuriosityModule.h:43
SmartEngine::CuriosityModuleCInfo::sequenceLength
int sequenceLength
The sequence length to use when using an agent graph that requires stepping (such as the inclusion of...
Definition: CuriosityModule.h:81
SmartEngine::CuriosityModuleCInfo::inverseForwardLossWeight
float inverseForwardLossWeight
A sliding [0..1] value that specifies how much we weight training the internal forward network (Predi...
Definition: CuriosityModule.h:76
SmartEngine::ObjectPtr
Smart pointer to an IObject. Automatic ref counting.
Definition: ObjectPtr.h:16
SmartEngine::GradientDescentTrainingInfo
GradientDescentTrainer training info
Definition: GradientDescentTrainer.h:74
SmartEngine
Definition: A2CTrainer.h:10
SmartEngine::IObject
Base class for SmartEngine AI objects. It is not common to deal with this class directly.
Definition: Object.h:19
SmartEngine::CuriosityModuleCInfo::graph
IGraph * graph
The agent graph for the constructed curiosity graph.
Definition: CuriosityModule.h:27
SmartEngine::CuriosityModuleCInfo::actionNodeNamesCount
int actionNodeNamesCount
The size of the action node name array.
Definition: CuriosityModule.h:37
SmartEngine::CuriosityModuleCInfo::normalizeRewards
bool normalizeRewards
True if we should normalize the rewards. This will turn large and small rewards into a normal curve.
Definition: CuriosityModule.h:61
SmartEngine::ICuriosityModule
A curiosity module is a way of rewarding an agent for behavior not yet seen. Rewards are given based ...
Definition: CuriosityModule.h:108
SmartEngine::ICuriosityModule::GetReward
virtual float GetReward()=0
Returns the sum rewards of the last batch of data processed. Useful for giving an idea of how much re...
SmartEngine::IGraph
A graph is a collection of buffers and nodes that together form a neural network. The graph is create...
Definition: Graph.h:61
SmartEngine::CreateCuriosityModule
SMARTENGINE_EXPORT ObjectPtr< ICuriosityModule > CreateCuriosityModule(const CuriosityModuleCInfo &cinfo)
Creates an instance of IA2CTrainer
SmartEngine::ICuriosityModule::GetLoss
virtual float GetLoss()=0
Returns the loss of the last batch processed. The loss represents how well the internal models are at...
SmartEngine::CuriosityModuleCInfo::actionNodeNames
const char ** actionNodeNames
The list of action output nodes in the agent graph that we will track.
Definition: CuriosityModule.h:32
SmartEngine::IResource
Base class for objects that can be loaded from and saved to disk.
Definition: Resource.h:77
SmartEngine::IContext
Every node in the AI graph must belong to the same context.
Definition: Context.h:40
SmartEngine::CuriosityModuleCInfo::rewardMultiplier
float rewardMultiplier
The factor that is multiplied with the generated rewards.
Definition: CuriosityModule.h:48