Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Graph

Graph is the primary container structure for deeplearn.js operations. Graph holds the topology of operation nodes and the connectivity between them.

Hierarchy

  • Graph

Index

Constructors

constructor

Properties

layers

layers: GraphLayers

Methods

add

  • Adds two tensors (elementwise). Broadcasts if one of the tensors is scalar.

    Parameters

    • x1: Tensor

      The first input tensor.

    • x2: Tensor

      The second input tensor.

    Returns Tensor

    The tensor representing t1+t2.

argmax

  • Returns the flattened index of the maximum entry in the tensor.

    Parameters

    • x: Tensor

      The tensor with the value.

    Returns Tensor

    A Scalar tensor with the index of the maximum entry.

argmaxEquals

  • Creates an argmax equals operation in the graph.

    Parameters

    • x1: Tensor

      First input tensor to check against.

    • x2: Tensor

      Second input tensor to check against.

    Returns Tensor

    The tensor representing the argmax equals operation.

concat3d

  • Concats two 3D tensors along a given axis.

    Parameters

    • x1: Tensor

      The first input tensor.

    • x2: Tensor

      The second input tensor.

    • axis: number

    Returns Tensor

    The tensor representing concat of two tensors along axis.

constant

  • constant(value: ArrayData): Tensor
  • Constant value that persists across session calls.

    Parameters

    • value: ArrayData

      The value to return.

    Returns Tensor

    A node outputing the constant value.

conv2d

  • conv2d(x: Tensor, w: Tensor, b: Tensor, fieldSize: number, outputDepth: number, stride?: number, zeroPad?: number): Tensor
  • Computes a 2D convolution.

    Parameters

    • x: Tensor

      The input tensor to the convolution operation.

    • w: Tensor

      The weight tensor used by the convolution operation.

    • b: Tensor

      The bias tensor used by the convolution operation.

    • fieldSize: number

      The size of the convolutional kernel.

    • outputDepth: number

      The output depth of the convolution operation.

    • Default value stride: number = 1

      The stride of the convolution operation.

    • Optional zeroPad: number

      The amount of zero padding on all sides of the input tensor.

    Returns Tensor

    The tensor representing the convolution operation.

divide

  • Divide two tensors (elementwise). Broadcasts if one of the tensors is scalar.

    Parameters

    • x1: Tensor

      The first input tensor.

    • x2: Tensor

      The second input tensor.

    Returns Tensor

    The tensor representing t1 / t2.

elu

  • Computes Elu of x element-wise.

    Parameters

    • x: Tensor

      the input tensor to the Elu.

    Returns Tensor

    The tensor representing the Elu operation.

exp

  • Computes exponential of x element-wise.

    Parameters

    • x: Tensor

      The input tensor to the exp.

    Returns Tensor

    The tensor representing the e ^ x operation.

fusedLinearCombination

  • Computes a fused linear combination of two tensors.

    Parameters

    • x1: Tensor

      The first input tensor.

    • x2: Tensor

      The second input tensor. Same shape as t1.

    • c1: Tensor

      Coefficient of t1. Must be size 1.

    • c2: Tensor

      Coefficient of t2. Must be size 1.

    Returns Tensor

    The tensor representing c1t1+c2t2.

getNodes

  • getNodes(): Node[]

leakyRelu

  • Computes LeakyReLU of x element-wise.

    Parameters

    • x: Tensor

      The input tensor to the LeakyReLU.

    • alpha: number

      Negative slope coefficient.

    Returns Tensor

    The tensor representing the LeakyReLU operation.

log

  • Computes log of x element-wise.

    Parameters

    • x: Tensor

      The input tensor to the log.

    Returns Tensor

    The tensor representing the ln(x) operation.

matmul

  • Computes the dot product between two matrices.

    Parameters

    • x1: Tensor

      The first input tensor.

    • x2: Tensor

      The second input tensor.

    Returns Tensor

    The tensor representing the dot product of x1 and x2.

maxPool

  • maxPool(x: Tensor, fieldSize: number, stride?: number, zeroPad?: number): Tensor
  • Computes a 2D max pool of x.

    Parameters

    • x: Tensor

      The input tensor to the max pool operation.

    • fieldSize: number

      The size of the convolutional kernel.

    • Default value stride: number = 1

      The stride of the convolution operation.

    • Optional zeroPad: number

      The amount of zero padding on all sides of the input tensor.

    Returns Tensor

    The tensor representing the max pool operation.

meanSquaredCost

  • Creates a mean-squared cost operation in the graph.

    Parameters

    • label: Tensor

      The label tensor.

    • prediction: Tensor

      The prediction tensor.

    Returns Tensor

    The tensor representing the mean-squared cost operation.

multiply

  • Multiply two tensors (elementwise). Broadcasts if one of the tensors is scalar.

    Parameters

    • x1: Tensor

      The first input tensor.

    • x2: Tensor

      The second input tensor.

    Returns Tensor

    The tensor representing t1*t2.

placeholder

  • placeholder(name: string, shape: number[]): Tensor
  • Inserts a placeholder for a tensor that will be always fed. Placeholders are input tensors whose values are provided by the client via feed dictionaries. Placeholders are not updated as part of training; they are only used as immutable input.

    Parameters

    • name: string

      The name of this placeholder.

    • shape: number[]

      The shape of the placeholder tensor.

    Returns Tensor

    The tensor representing the placeholder.

reduceSum

relu

  • Computes ReLU of x element-wise.

    Parameters

    • x: Tensor

      The input tensor to the ReLU.

    Returns Tensor

    The tensor representing the ReLU operation.

reshape

  • Reshape the input tensor.

    Parameters

    • x: Tensor

      The input tensor to be reshaped.

    • shape: number[]

      The shape of the output tensor.

    Returns Tensor

    The tensor representing the reshape operation.

sigmoid

  • Computes Sigmoid of x element-wise.

    Parameters

    • x: Tensor

      The input tensor to the sigmoid.

    Returns Tensor

    The tensor representing the sigmoid operation.

softmax

  • Computes softmax probabilities from logits.

    Parameters

    Returns Tensor

    The softmax probabilities.

softmaxCrossEntropyCost

  • Creates a softmax cross-entropy cost operation in the graph.

    Parameters

    • x: Tensor

      The input tensor to classify.

    • target: Tensor

      The label tensor.

    Returns Tensor

    The tensor representing the softmax cross-entropy cost operation.

square

subtract

  • Subtracts two tensors (elementwise). Broadcasts if one of the tensors is scalar.

    Parameters

    • x1: Tensor

      The first input tensor.

    • x2: Tensor

      The second input tensor.

    Returns Tensor

    The tensor representing t1-t2.

tanh

  • Computes TanH of x element-wise.

    Parameters

    • x: Tensor

      The input tensor to the TanH.

    Returns Tensor

    The tensor representing the TanH operation.

variable

  • Creates a named variable. Variables are tensors that maintain state across session calls and whose values are adjusted during backpropagation training.

    Parameters

    • name: string

      The name of this variable.

    • data: NDArray

      The NDArray to associate with this variable tensor.

    Returns Tensor

    The tensor representing the variable.

Generated using TypeDoc