KGraph

class KGraph(graphDef: ByteArray, prefix: String) : AutoCloseable

A wrapper object to extend functionality and behaviour of static TensorFlow graph.

It tracks all model variables (used in optimizers or layers) and its initializers.

Parameters

graphDef

A serialized representation of the graph.

prefix

A prefix that will be prepended to names in graphDef.

Constructors

KGraph
Link copied to clipboard
fun KGraph(graphDef: ByteArray)
KGraph
Link copied to clipboard
fun KGraph(graphDef: ByteArray, prefix: String)

Creates KGraph by serialized representation of the graph.

Functions

addInitializer
Link copied to clipboard
fun addInitializer(variableName: String, initializer: Assign<Float>)

Adds an initializer for layer variable tracked in KGraph.

addLayerVariable
Link copied to clipboard
fun addLayerVariable(variable: Variable<Float>, isTrainable: Boolean)

Adds a variable used in layer to the pool of tracked variables.

addOptimizerVariable
Link copied to clipboard
fun addOptimizerVariable(variable: Variable<Float>)

Adds a variable used in optimizer to the pool of tracked variables.

fun addOptimizerVariableAssignAddInitializer(initializer: AssignAdd<Float>)

Adds an optimizer initializer of special 'AssignAdd' type for optimizer variable tracked in KGraph.

addOptimizerVariableInitializer
Link copied to clipboard
fun addOptimizerVariableInitializer(initializer: Assign<*>)

Adds an optimizer initializer for optimizer variable tracked in KGraph.

addVariableRegularizer
Link copied to clipboard
fun addVariableRegularizer(variable: Variable<Float>, regularizer: Regularizer)

Adds a variable related to the given regularizer to the pool of tracked variables.

close
Link copied to clipboard
open override fun close()

Closes internal TensorFlow graph.

copy
Link copied to clipboard
fun copy(): KGraph

Makes a graph copy.

frozenLayerVariables
Link copied to clipboard
fun frozenLayerVariables(): List<Variable<Float>>

Returns a list of non-trainable, 'frozen' variables used in layers.

initializeGraphVariables
Link copied to clipboard
fun initializeGraphVariables(session: Session)

Initializes TensorFlow graph variables used in model layers.

initializeOptimizerVariables
Link copied to clipboard
fun initializeOptimizerVariables(session: Session)

Initializes TensorFlow graph variables used in optimizer.

isVariableTrainable
Link copied to clipboard
fun isVariableTrainable(variableName: String): Boolean

Returns the variable's ability to be changed during the training.

layerVariables
Link copied to clipboard
fun layerVariables(): List<Variable<Float>>

Returns all variables used in all model layers.

optimizerVariables
Link copied to clipboard
fun optimizerVariables(): List<Variable<Float>>

Returns all variables used in optimizer and initialized by Assign TensorFlow operand.

toString
Link copied to clipboard
open override fun toString(): String
trainableLayerVariables
Link copied to clipboard
fun trainableLayerVariables(): List<Variable<Float>>

Returns a list of trainable variables used in layers.

variableNames
Link copied to clipboard
fun variableNames(): List<String>

Returns list of variable names in TensorFlow graph.

Properties

isClosed
Link copied to clipboard
var isClosed: Boolean = false

True if the graph object is closed and the occupied resources are freed.