Options
All
  • Public
  • Public/Protected
  • All
Menu

Class for sampling from a multivariate Gaussian distribution.

Hierarchy

  • Layer
    • SamplingLayer

Index

Constructors

constructor

Properties

Protected _refCount

_refCount: number | null

Protected _stateful

_stateful: boolean

Protected _trainableWeights

_trainableWeights: LayerVariable[]

activityRegularizer

activityRegularizer: Regularizer

batchInputShape

batchInputShape: Shape

built

built: boolean

dtype

dtype: DataType

id

id: number

inboundNodes

inboundNodes: Node[]

initialWeights

initialWeights: Tensor[]

input

input: SymbolicTensor | SymbolicTensor[]

Retrieves the input tensor(s) of a layer.

Only applicable if the layer has exactly one inbound node, i.e. if it is connected to one incoming layer.

returns

Input tensor or list of input tensors.

exception

AttributeError if the layer is connected to more than one incoming layers.

inputSpec

inputSpec: InputSpec[]

List of InputSpec class instances.

Each entry describes one required input:

  • ndim
  • dtype A layer with n input tensors must have an inputSpec of length n.

losses

losses: RegularizerFn[]

name

name: string

Name for this layer. Must be unique within a model.

nonTrainableWeights

nonTrainableWeights: LayerVariable[]

outboundNodes

outboundNodes: Node[]

output

output: SymbolicTensor | SymbolicTensor[]

Retrieves the output tensor(s) of a layer.

Only applicable if the layer has exactly one inbound node, i.e. if it is connected to one incoming layer.

returns

Output tensor or list of output tensors.

exception

AttributeError if the layer is connected to more than one incoming layers.

outputShape

outputShape: Shape | Shape[]
doc

{heading: 'Models', 'subheading': 'Classes'}

stateful

stateful: boolean

supportsMasking

supportsMasking: boolean

trainable

trainable: boolean

trainableWeights

trainableWeights: LayerVariable[]

Protected trainable_

trainable_: boolean

Whether the layer weights will be updated during training.

updates

updates: Tensor[]

weights

weights: LayerVariable[]

The concatenation of the lists trainableWeights and nonTrainableWeights (in this order).

Methods

addLoss

  • addLoss(losses: RegularizerFn | RegularizerFn[]): void
  • doc

    {heading: 'Models', 'subheading': 'Classes'}

    Parameters

    • losses: RegularizerFn | RegularizerFn[]

    Returns void

Protected addWeight

  • addWeight(name: string, shape: Shape, dtype?: DataType, initializer?: Initializer, regularizer?: Regularizer, trainable?: boolean, constraint?: Constraint): LayerVariable
  • doc

    {heading: 'Models', 'subheading': 'Classes'}

    Parameters

    • name: string
    • shape: Shape
    • Optional dtype: DataType
    • Optional initializer: Initializer
    • Optional regularizer: Regularizer
    • Optional trainable: boolean
    • Optional constraint: Constraint

    Returns LayerVariable

apply

  • apply(inputs: Tensor | Tensor[] | SymbolicTensor | SymbolicTensor[], kwargs?: Kwargs): Tensor | Tensor[] | SymbolicTensor | SymbolicTensor[]
  • doc

    {heading: 'Models', 'subheading': 'Classes'}

    Parameters

    • inputs: Tensor | Tensor[] | SymbolicTensor | SymbolicTensor[]
    • Optional kwargs: Kwargs

    Returns Tensor | Tensor[] | SymbolicTensor | SymbolicTensor[]

Protected assertInputCompatibility

  • assertInputCompatibility(inputs: Tensor | Tensor[] | SymbolicTensor | SymbolicTensor[]): void
  • Checks compatibility between the layer and provided inputs.

    This checks that the tensor(s) input verify the input assumptions of the layer (if any). If not, exceptions are raised.

    exception

    ValueError in case of mismatch between the provided inputs and the expectations of the layer.

    Parameters

    • inputs: Tensor | Tensor[] | SymbolicTensor | SymbolicTensor[]

      Input tensor or list of input tensors.

    Returns void

Protected assertNotDisposed

  • assertNotDisposed(): void

build

  • build(inputShape: Shape | Shape[]): void
  • doc

    {heading: 'Models', 'subheading': 'Classes'}

    Parameters

    • inputShape: Shape | Shape[]

    Returns void

calculateLosses

  • calculateLosses(): Scalar[]
  • Retrieves the Layer's current loss values.

    Used for regularizers during training.

    Returns Scalar[]

call

  • call(inputs: [tf.Tensor2D, tf.Tensor2D]): Tensor<Rank>
  • Parameters

    • inputs: [tf.Tensor2D, tf.Tensor2D]

    Returns Tensor<Rank>

clearCallHook

  • clearCallHook(): void
  • Clear call hook. This is currently used for testing only.

    Returns void

computeMask

  • computeMask(inputs: Tensor | Tensor[], mask?: Tensor | Tensor[]): Tensor | Tensor[]
  • Computes an output mask tensor.

    Parameters

    • inputs: Tensor | Tensor[]

      Tensor or list of tensors.

    • Optional mask: Tensor | Tensor[]

      Tensor or list of tensors.

    Returns Tensor | Tensor[]

    null or a tensor (or list of tensors, one per output tensor of the layer).

computeOutputShape

  • computeOutputShape(inputShape: tf.Shape[]): number[]
  • Parameters

    • inputShape: tf.Shape[]

    Returns number[]

countParams

  • countParams(): number
  • doc

    {heading: 'Models', 'subheading': 'Classes'}

    Returns number

dispose

  • dispose(): DisposeResult
  • doc

    {heading: 'Models', 'subheading': 'Classes'}

    Returns DisposeResult

Protected disposeWeights

  • disposeWeights(): number
  • Dispose the weight variables that this Layer instance holds.

    Returns number

    Number of disposed variables.

getClassName

  • getClassName(): string

getConfig

  • getConfig(): ConfigDict
  • doc

    {heading: 'Models', 'subheading': 'Classes'}

    Returns ConfigDict

getInputAt

  • getInputAt(nodeIndex: number): SymbolicTensor | SymbolicTensor[]
  • Retrieves the input tensor(s) of a layer at a given node.

    Parameters

    • nodeIndex: number

      Integer, index of the node from which to retrieve the attribute. E.g. nodeIndex=0 will correspond to the first time the layer was called.

    Returns SymbolicTensor | SymbolicTensor[]

    A tensor (or list of tensors if the layer has multiple inputs).

getOutputAt

  • getOutputAt(nodeIndex: number): SymbolicTensor | SymbolicTensor[]
  • Retrieves the output tensor(s) of a layer at a given node.

    Parameters

    • nodeIndex: number

      Integer, index of the node from which to retrieve the attribute. E.g. nodeIndex=0 will correspond to the first time the layer was called.

    Returns SymbolicTensor | SymbolicTensor[]

    A tensor (or list of tensors if the layer has multiple outputs).

getWeights

  • getWeights(trainableOnly?: boolean): Tensor[]
  • doc

    {heading: 'Models', 'subheading': 'Classes'}

    Parameters

    • Optional trainableOnly: boolean

    Returns Tensor[]

Protected invokeCallHook

  • invokeCallHook(inputs: Tensor | Tensor[], kwargs: Kwargs): void
  • Parameters

    • inputs: Tensor | Tensor[]
    • kwargs: Kwargs

    Returns void

resetStates

  • resetStates(): void
  • Reset the states of the layer.

    This method of the base Layer class is essentially a no-op. Subclasses that are stateful (e.g., stateful RNNs) should override this method.

    Returns void

setCallHook

  • setCallHook(callHook: CallHook): void
  • Set call hook. This is currently used for testing only.

    Parameters

    • callHook: CallHook

    Returns void

setFastWeightInitDuringBuild

  • setFastWeightInitDuringBuild(value: boolean): void
  • Set the fast-weight-initialization flag.

    In cases where the initialized weight values will be immediately overwritten by loaded weight values during model loading, setting the flag to true saves unnecessary calls to potentially expensive initializers and speeds up the loading process.

    Parameters

    • value: boolean

      Target value of the flag.

    Returns void

setWeights

  • setWeights(weights: Tensor[]): void
  • doc

    {heading: 'Models', 'subheading': 'Classes'}

    Parameters

    • weights: Tensor[]

    Returns void

Protected warnOnIncompatibleInputShape

  • warnOnIncompatibleInputShape(inputShape: Shape): void
  • Check compatibility between input shape and this layer's batchInputShape.

    Print warning if any incompatibility is found.

    Parameters

    • inputShape: Shape

      Input shape to be checked.

    Returns void

Static fromConfig

  • fromConfig<T>(cls: SerializableConstructor<T>, config: ConfigDict): T
  • nocollapse

    Type parameters

    • T: Serializable

    Parameters

    • cls: SerializableConstructor<T>
    • config: ConfigDict

    Returns T

Static Protected nodeKey

  • nodeKey(layer: Layer, nodeIndex: number): string
  • Converts a layer and its index to a unique (immutable type) name. This function is used internally with this.containerNodes.

    Parameters

    • layer: Layer

      The layer.

    • nodeIndex: number

      The layer's position (e.g. via enumerate) in a list of nodes.

    Returns string

    The unique name.

Generated using TypeDoc