SmartEngine  1.6.0
Public Member Functions | Public Attributes | List of all members
SmartEngine::IGraph Class Referenceabstract

A graph is a collection of buffers and nodes that together form a neural network. The graph is created from a json definition file. After creation, the contents of the graph can be loaded from or saved to disk. More...

#include <Graph.h>

Inheritance diagram for SmartEngine::IGraph:
SmartEngine::IResource SmartEngine::IObject SmartEngine::ISerializable SmartEngine::IObject

Public Member Functions

virtual const char * GetName () const =0
 Returns the name of the graph. More...
 
virtual ObjectPtr< IContextGetContext () const =0
 Returns the context associated with the graph More...
 
virtual ObjectPtr< IGraphDeepCopy () const =0
 Copies the internal structure of the graph into a new graph More...
 
virtual ObjectPtr< IGraphInstance ()=0
 Creates a copy of this graph with all internal weights referenced to this graph. More...
 
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 included will be bound to buffer inputs. More...
 
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 have the same exact structure as this graph. More...
 
virtual void SetRandomWeights ()=0
 Initialize the weights trainable layers to random values. More...
 
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 is added to the graph. More...
 
template<typename T >
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 a different type. More...
 
virtual ObjectPtr< IGraphNodeGetOutputNode (int index) const =0
 Returns an output node of the graph as a GraphNode. The nodes are ordered in the appearance in the graph definition or the order they were added manually. More...
 
virtual float GetWeightStandardDeviation () const =0
 Returns the average standard deviation of all trainable weights in the graph. More...
 
virtual int GetSequenceLength () const =0
 Returns the desired sequence length for this graph. This is after how many steps the graph should be reset. Only applicable to graphs that need to be stepped (such as LSTMs). More...
 
virtual void SetSequenceLength (int stepCount)=0
 Sets the desired sequence length for this graph. This is after how many steps the graph should be reset. Only applicable to graphs that need to be stepped (such as LSTMs). More...
 
virtual void ResetNeuronLayers ()=0
 Calls Reset() on all trainable layers in the graph. This is only necessary for LSTM neuron layers. More...
 
virtual void StepNeuronLayers (bool autoReset=true)=0
 Calls Step() on all trainable layers in the graph. This is only necessary for LSTM neuron layers. More...
 
- Public Member Functions inherited from SmartEngine::IResource
virtual const char * GetResourceName () const =0
 Returns the name of this resource passed to the constructor. More...
 
virtual SerializationResult GetLastLoadResult () const =0
 Returns the result of the last call to Load(). Useful for checking loaded data state after creation. More...
 
virtual SerializationResult Load (const char *appendName=nullptr)=0
 Load this object from disk. More...
 
virtual SerializationResult Save (const char *appendName=nullptr)=0
 Save this object to disk. More...
 
- Public Member Functions inherited from SmartEngine::IObject
virtual ObjectId GetId () const =0
 Returns the ID of this object. More...
 
virtual void AddRef () const =0
 Increments the internal reference count on this object. It is not common to use this method directly. More...
 
virtual void Release () const =0
 Decrements the internal reference count on this object. It is not common to use this method directly. More...
 
virtual int GetRefCount () const =0
 Returns the number of references to this object. More...
 
virtual void * QueryInterface (ObjectClassId id)=0
 Queries the object for an interface and returns a pointer to that interface if found. More...
 
void operator= (IObject const &x)=delete
 
- Public Member Functions inherited from SmartEngine::ISerializable
virtual SerializationResult Serialize (IMemoryBuffer *buffer)=0
 Write the contents of this object to a buffer. More...
 
virtual SerializationResult Deserialize (IMemoryBuffer *buffer)=0
 Fill this object with contents from a buffer. More...
 

Public Attributes

 private
 
 __pad0__: virtual ObjectPtr<IGraphNode> GetNodeInternal(const char* name) const = 0
 
- Public Attributes inherited from SmartEngine::IObject
 private
 
 __pad0__: IObject() {} IObject(IObject const&) = delete
 

Detailed Description

A graph is a collection of buffers and nodes that together form a neural network. The graph is created from a json definition file. After creation, the contents of the graph can be loaded from or saved to disk.

When loading from a resource, two assets will try to load. One will be the resourceName + "Definition", which should be a json text asset. The other will be resourceName + "Data", which will be the graph data. The definition is required, but the data can be missing on creation.

Member Function Documentation

◆ AddNode()

virtual void SmartEngine::IGraph::AddNode ( IGraphNode node)
pure virtual

Adds a node to the graph. This will be considered an output node until a node connecting to this one is added to the graph.

Parameters
node

◆ BindComponentInputs()

virtual void SmartEngine::IGraph::BindComponentInputs ( const ComponentInputBinding bindings,
int  bindingCount 
)
pure virtual

Binds the component inputs in the graph to the specified set of nodes. Any component inputs not included will be bound to buffer inputs.

This should only be called once before first evaluation. It is not necessary to call this if the graph is used as a graph component or added as a standard graph model to a graph manager.

Called automatically by IGraphComponent upon creation.

Any created buffer inputs will have the name "[Comp Input Name]Buffer" and will be added to the graph. (Ex: "MyCompInput" would have a buffer "MyCompInputBuffer" that can be queried through normal means)

Parameters
bindings
bindingCount

◆ CopyWeightsFrom()

virtual void SmartEngine::IGraph::CopyWeightsFrom ( IGraph graph,
float  percent = 1.0f 
)
pure virtual

Copies the neuron layer weights from the specified graph into this graph. The specified graph must have the same exact structure as this graph.

Parameters
graph

◆ DeepCopy()

virtual ObjectPtr<IGraph> SmartEngine::IGraph::DeepCopy ( ) const
pure virtual

Copies the internal structure of the graph into a new graph

Returns

◆ GetContext()

virtual ObjectPtr<IContext> SmartEngine::IGraph::GetContext ( ) const
pure virtual

Returns the context associated with the graph

Returns

◆ GetName()

virtual const char* SmartEngine::IGraph::GetName ( ) const
pure virtual

Returns the name of the graph.

◆ GetNode()

template<typename T >
ObjectPtr< T > SmartEngine::IGraph::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 a different type.

Template Parameters
T
Parameters
name
Returns

◆ GetOutputNode()

virtual ObjectPtr<IGraphNode> SmartEngine::IGraph::GetOutputNode ( int  index) const
pure virtual

Returns an output node of the graph as a GraphNode. The nodes are ordered in the appearance in the graph definition or the order they were added manually.

Parameters
index
Returns

◆ GetSequenceLength()

virtual int SmartEngine::IGraph::GetSequenceLength ( ) const
pure virtual

Returns the desired sequence length for this graph. This is after how many steps the graph should be reset. Only applicable to graphs that need to be stepped (such as LSTMs).

◆ GetWeightStandardDeviation()

virtual float SmartEngine::IGraph::GetWeightStandardDeviation ( ) const
pure virtual

Returns the average standard deviation of all trainable weights in the graph.

Returns

◆ Instance()

virtual ObjectPtr<IGraph> SmartEngine::IGraph::Instance ( )
pure virtual

Creates a copy of this graph with all internal weights referenced to this graph.

◆ ResetNeuronLayers()

virtual void SmartEngine::IGraph::ResetNeuronLayers ( )
pure virtual

Calls Reset() on all trainable layers in the graph. This is only necessary for LSTM neuron layers.

◆ SetRandomWeights()

virtual void SmartEngine::IGraph::SetRandomWeights ( )
pure virtual

Initialize the weights trainable layers to random values.

◆ SetSequenceLength()

virtual void SmartEngine::IGraph::SetSequenceLength ( int  stepCount)
pure virtual

Sets the desired sequence length for this graph. This is after how many steps the graph should be reset. Only applicable to graphs that need to be stepped (such as LSTMs).

◆ StepNeuronLayers()

virtual void SmartEngine::IGraph::StepNeuronLayers ( bool  autoReset = true)
pure virtual

Calls Step() on all trainable layers in the graph. This is only necessary for LSTM neuron layers.

Parameters
autoResetIf true, ResetNeuronLayers() will automatically be called periodically based on the sequence length.

Member Data Documentation

◆ __pad0__

SmartEngine::IGraph::__pad0__

◆ private

SmartEngine::IGraph::private