Graph
public protocol Graph
Basic graph protocol
-
List of
GraphSymbol
. Key is theUID
of symbol object in value field.Declaration
Swift
var symbols: [String: GraphSymbol]
-
The readable label of this graph
Declaration
Swift
var graphLabel: String
-
If this graph is trainable.
Declaration
Swift
var trainable: Bool
-
Description of this graph
Declaration
Swift
var description: String
-
Optimizer of this graph doing backward training. Could be
nil
if just do forward calcualtion.Declaration
Swift
var optimizer: Optimizer?
-
Counter of backward training
Declaration
Swift
var epoch: Int
-
Add a
TensorSymbol
to the graph.Declaration
Swift
func tensor(_ label: String?, shape: TensorShape) -> TensorSymbol
Parameters
label
label description
shape
shape description
Return Value
return value description
-
Add a
ScalarSymbol
to the graph.Declaration
Swift
func scalar(_ label: String?, dataType: TensorDataType) -> ScalarSymbol
Parameters
label
label
Return Value
-
Add a
OperatorSymbol
to the graph.Declaration
Swift
func operation(_ label: String?, inputs: [TensorSymbol], op: ComputableOperator) -> (outputTensorSymbols: [TensorSymbol], operatorSymbol: OperatorSymbol, paramSymbols: [GraphSymbol])
Parameters
inputs
input array of
TensorSymbol
op
A
ComputableOperator
instanceReturn Value
Output
TensorSymbol
fromoperator
calculation, and constructedOperatorSymbol
-
Forward computing from inputs to outputs.
Declaration
Swift
func forward(mode: OperatorComputationMode)
Parameters
mode
computation mode
-
Backward computing the grads for updatable data symbols.
Declaration
Swift
func backward(mode: OperatorComputationMode)
Parameters
mode
computation mode
-
Bind data to
TensorSymbol
.Declaration
Swift
func bindData(_ data: [String: DataSymbolSupportedDataType])
Parameters
data
A dictinary whose key is
label
of aTensorSymbol
and value is an array ofDataSymbolSupportedDataType
objects. -
addSymbols(_:)
Default implementationAdd symbol to
symbols
. Should check duplicateDefault Implementation
Add symbol to
symbols
. Should check duplicateDeclaration
Swift
func addSymbols(_ symbol: GraphSymbol)
Parameters
symbol
new symbol