14 struct GraphCInfo :
public ResourceCInfo
63 SMARTENGINE_DECLARE_CLASS(
IGraph)
66 virtual const char* GetName()
const = 0;
133 template <
typename T>
ObjectPtr<T> GetNode(
const char* name)
const;
194 const char* resourceName =
nullptr);
199 SMARTENGINE_EXPORT ObjPtr Graph_CreateEmpty(
const GraphCInfo& cinfo);
200 SMARTENGINE_EXPORT ObjPtr Graph_CreateFromDefinition(
const GraphCInfo& cinfo,
const char* graphDefinition);
201 SMARTENGINE_EXPORT ObjPtr Graph_CreateFromResource(
const GraphCInfo& cinfo,
const char* resourceName);
202 SMARTENGINE_EXPORT
const char* Graph_GetName(ObjPtr
object);
203 SMARTENGINE_EXPORT ObjPtr Graph_GetContext(ObjPtr
object);
204 SMARTENGINE_EXPORT ObjPtr Graph_DeepCopy(ObjPtr
object);
205 SMARTENGINE_EXPORT ObjPtr Graph_Instance(ObjPtr
object);
206 SMARTENGINE_EXPORT
void Graph_BindComponentInputs(ObjPtr
object,
const ComponentInputBinding* bindings,
int bindingCount);
207 SMARTENGINE_EXPORT
void Graph_CopyWeightsFrom(ObjPtr
object, ObjPtr graph,
float percent);
208 SMARTENGINE_EXPORT
void Graph_SetRandomWeights(ObjPtr
object);
209 SMARTENGINE_EXPORT ObjPtr Graph_GetNode(ObjPtr
object,
const char* name,
const char* type);
210 SMARTENGINE_EXPORT ObjPtr Graph_GetOutputNode(ObjPtr
object,
int index);
211 SMARTENGINE_EXPORT
float Graph_GetWeightStandardDeviation(ObjPtr
object);
212 SMARTENGINE_EXPORT
void Graph_AddNode(ObjPtr
object, ObjPtr node);
213 SMARTENGINE_EXPORT
int Graph_GetSequenceLength(ObjPtr
object);
214 SMARTENGINE_EXPORT
void Graph_SetSequenceLength(ObjPtr
object,
int stepCount);
215 SMARTENGINE_EXPORT
void Graph_ResetNeuronLayers(ObjPtr
object);
216 SMARTENGINE_EXPORT
void Graph_StepNeuronLayers(ObjPtr
object,
int autoReset);
222 return DynamicCast<T>(GetNodeInternal(name));
A logical node in the AI graph. Some nodes, like NeuralNetwork, are composed of other nodes (neuron l...
Definition: GraphNode.h:34
virtual int GetSequenceLength() const =0
Returns the desired sequence length for this graph. This is after how many steps the graph should be ...
virtual void SetSequenceLength(int stepCount)=0
Sets the desired sequence length for this graph. This is after how many steps the graph should be res...
virtual void BindComponentInputs(const ComponentInputBinding *bindings, int bindingCount)=0
Binds the component inputs in the graph to the specified set of nodes. Any component inputs not inclu...
SMARTENGINE_EXPORT ObjectPtr< IGraph > CreateGraphFromResource(const GraphCInfo &cinfo, const char *resourceName=nullptr)
Creates and loads a new IGraph from a resource.
virtual void SetRandomWeights()=0
Initialize the weights trainable layers to random values.
virtual void ResetNeuronLayers()=0
Calls Reset() on all trainable layers in the graph. This is only necessary for LSTM neuron layers.
Data used to construct an IGraph instance
Definition: Graph.h:18
virtual void StepNeuronLayers(bool autoReset=true)=0
Calls Step() on all trainable layers in the graph. This is only necessary for LSTM neuron layers.
virtual ObjectPtr< IGraph > DeepCopy() const =0
Copies the internal structure of the graph into a new graph
IContext * context
The context this graph belongs to.
Definition: Graph.h:22
ObjectPtr< T > GetNode(const char *name) const
Returns the specified node as the specified type. Null is returned if the node is not found or is of ...
Definition: Graph.h:220
virtual float GetWeightStandardDeviation() const =0
Returns the average standard deviation of all trainable weights in the graph.
virtual void AddNode(IGraphNode *node)=0
Adds a node to the graph. This will be considered an output node until a node connecting to this one ...
Smart pointer to an IObject. Automatic ref counting.
Definition: ObjectPtr.h:16
Definition: A2CTrainer.h:10
SMARTENGINE_EXPORT ObjectPtr< IGraph > CreateGraphFromDefinition(const GraphCInfo &cinfo, const char *graphDefinition)
Creates a new IGraph from a graph definition json string.
virtual ObjectPtr< IGraphNode > GetOutputNode(int index) const =0
Returns an output node of the graph as a GraphNode. The nodes are ordered in the appearance in the gr...
A graph is a collection of buffers and nodes that together form a neural network. The graph is create...
Definition: Graph.h:61
virtual void CopyWeightsFrom(IGraph *graph, float percent=1.0f)=0
Copies the neuron layer weights from the specified graph into this graph. The specified graph must ha...
Base class for objects that can be loaded from and saved to disk.
Definition: Resource.h:77
SMARTENGINE_EXPORT ObjectPtr< IGraph > CreateEmptyGraph(const GraphCInfo &cinfo)
Creates a new, empty IGraph instance.
Every node in the AI graph must belong to the same context.
Definition: Context.h:40
virtual ObjectPtr< IContext > GetContext() const =0
Returns the context associated with the graph
virtual ObjectPtr< IGraph > Instance()=0
Creates a copy of this graph with all internal weights referenced to this graph.