Options
All
  • Public
  • Public/Protected
  • All
Menu

Main SketchRNN model class.

Implementation of decoder model in https://arxiv.org/abs/1704.03477

TODO(hardmaru): make a "batch" continueSequence-like method that runs fully on GPU.

Hierarchy

  • SketchRNN

Index

Constructors

constructor

  • new SketchRNN(checkpointURL: string): SketchRNN

Properties

info

numUnits

numUnits: number

pixelFactor

pixelFactor: number

scaleFactor

scaleFactor: number

Methods

copyState

dispose

  • dispose(): void

getPDF

  • Given the RNN state, returns the probabilty distribution function (pdf) of the next stroke. Optionally adjust the temperature of the pdf here.

    Parameters

    • state: LSTMState

      previous LSTMState.

    • Default value temperature: number = 0.65

      (Optional) for dx and dy (default 0.65)

    • Optional softmaxTemperature: number

      (Optional) for Pi and Pen discrete states (default is temperature * 0.5 + 0.5, which is a nice heuristic.)

    Returns StrokePDF

    StrokePDF (pi, muX, muY, sigmaX, sigmaY, corr, pen)

initialize

  • initialize(): Promise<void>

isInitialized

  • isInitialized(): boolean

lineToStroke

  • lineToStroke(line: number[][], lastPoint: number[]): number[][]
  • Convert from a line format to stroke-5

    Parameters

    • line: number[][]

      list of points [[x0, y0], [x1, y1], ...]

    • lastPoint: number[]

      the absolute position of the last point

    Returns number[][]

    stroke-5 format of the line, list of [dx, dy, p0, p1, p2]

linesToStroke

  • linesToStroke(lines: number[][][]): number[][]
  • Convert from polylines to stroke-5 format that sketch-rnn uses

    Parameters

    • lines: number[][][]

      list of points each elem is ([[x0, y0], [x1, y1], ...])

    Returns number[][]

    stroke-5 format of the line, list of [dx, dy, p0, p1, p2]

sample

  • Samples the next point of the sketch given pdf parameters

    Parameters

    Returns number[]

setPixelFactor

  • setPixelFactor(scale: number): void
  • Sets the internal EXTRA factor of this model (pixel to model space)

    Parameters

    • scale: number

      (the extra scale factor for pixel to model space)

    Returns void

    nothing

simplifyLine

  • simplifyLine(line: number[][], tolerance?: number): number[][]
  • Simplifies line using RDP algorithm

    Parameters

    • line: number[][]

      list of points [[x0, y0], [x1, y1], ...]

    • Optional tolerance: number

      (Optional) default 2.0

    Returns number[][]

    simpified line [[x0', y0'], [x1', y1'], ...]

simplifyLines

  • simplifyLines(lines: number[][][], tolerance?: number): number[][][]
  • Simplifies lines using RDP algorithm

    Parameters

    • lines: number[][][]
    • Optional tolerance: number

      (Optional) default 2.0

    Returns number[][][]

    simpified lines (each elem is [[x0', y0'], [x1', y1'], ...])

update

updateStrokes

  • Updates the RNN on a series of Strokes, returns the next state.

    Parameters

    • strokes: number[][]

      list of [dx, dy, penDown, penUp, penEnd].

    • state: LSTMState

      previous LSTMState.

    • Optional steps: number

      (Optional) number of steps of the stroke to update (default is length of strokes list)

    Returns LSTMState

    the final LSTMState.

zeroInput

  • zeroInput(): number[]

zeroState

  • Returns the zero/initial state of the model

    Returns LSTMState

    zero state of the lstm: [c, h], where c and h are zero vectors.

Generated using TypeDoc