graph

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2023 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveFile

func SaveFile(graphDef *Def, filename string) error

SaveFile saves graph to a file based on extension .pb, .pbtxt, .pbtext, .json. No extension is considered as binary proto format equivalent to .pb extension

Types

type Def

type Def struct {
	// contains filtered or unexported fields
}

Def wraps proto definition of graphdef to define a few utility methods on it

func LoadFile

func LoadFile(filename string) (*Def, error)

LoadFile imports graph from a file formatted as either binary protobuf, protobuf text or json

func NewGraphDef

func NewGraphDef() (*Def, error)

NewGraphDef provides a new instance of Def

func (*Def) Append

func (g *Def) Append(graphDef *Def) error

Append appends input graphDef to the receiver thereby growing the node pool of receiver graph

func (*Def) ApplyPrefix

func (g *Def) ApplyPrefix(prefix string) error

ApplyPrefix applies input prefix to all node names and also changes the input strings where these nodes are being referred to

func (*Def) DeleteNode

func (g *Def) DeleteNode(nodeName string)

DeleteNode deletes a node from the graph

func (*Def) DeleteNodes

func (g *Def) DeleteNodes(nodeNames ...string) error

DeleteNodes deletes provided node names if they exist

func (*Def) Export

func (g *Def) Export(prefix string) (*tf.Graph, error)

Export translates Def to tensorflow Graph so it can be used in session runs

func (*Def) GetNode

func (g *Def) GetNode(nodeName string) (*node.Def, error)

GetNode returns a node.Def. Each graph is essentially just a list of nodes and links between nodes is defined via node inputs

func (*Def) GetNodes

func (g *Def) GetNodes(nodeNames ...string) ([]*node.Def, error)

GetNodes returns list of nodes based on input names. Input names should only contain names present in the graph, otherwise an error is returned

func (*Def) Import

func (g *Def) Import(graph *tf.Graph) error

Import converts tensorflow Graph format to Def. In some ways tensorflow Graph can be thought of as higher level construct and Def allows looking into nodes and attributes at a raw level

func (*Def) ListNodes

func (g *Def) ListNodes(options ...ListNodesOption) []string

ListNodes returns node names and filters them via options. Options are function literals that answer bool on each node. Thus, each option, if any is provided, should be satisfied

func (*Def) MarshalJSON

func (g *Def) MarshalJSON() ([]byte, error)

MarshalJSON defines how receiver can be json marshaled

func (*Def) PrintDotNotation

func (g *Def) PrintDotNotation() ([]byte, error)

PrintDotNotation defines how receiver can be printed as a dot notation for visualization via graphviz https://graphviz.org/doc/info/lang.html

func (*Def) ProtoReflect

func (g *Def) ProtoReflect() protoreflect.Message

ProtoReflect defines how receiver can be proto marshaled and unmarshaled

func (*Def) RenameNode

func (g *Def) RenameNode(name, newName string) error

RenameNode only changes the name of a particular node if it exists without affecting the inputs where such node name is being referred. newName should not collide with an existing name

func (*Def) Reset

func (g *Def) Reset()

Reset resets underlying graphDef proto

func (*Def) SetNodes

func (g *Def) SetNodes(nodeDefs ...*node.Def)

SetNodes will overwrite nodes in the graph with same name or append to graph if the name is not found

func (*Def) String

func (g *Def) String() string

String defines how receiver can be printed

func (*Def) UnmarshalJSON

func (g *Def) UnmarshalJSON(data []byte) error

UnmarshalJSON defines how receiver can be json unmarshaled

type ListNodesOption

type ListNodesOption func(def *node.Def) bool

ListNodesOption is a func that answers yes/no on a node. Such options can be provided to filter node list

func ListNodesOptionOp

func ListNodesOptionOp(op string) ListNodesOption

ListNodesOptionOp takes op as a string and checks if node op matches it

func ListNodesOptionWithInputs

func ListNodesOptionWithInputs(inputs ...string) ListNodesOption

ListNodesOptionWithInputs checks if each of the inputs for a node matches one from the input

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL