Class TextEmbedding

Text Embedding with Tensorflow Universal Sentence Encoder (USE)

Implements

Hierarchy

Constructors

  • new TextEmbedding(options?: TensorScriptOptions, properties?: TensorScriptProperties): TextEmbedding

Properties

compiled: boolean
getInputShape: ((...args: any[]) => any)

Type declaration

    • (...args: any[]): any
    • Parameters

      • Rest ...args: any[]

      Returns any

getTimeseriesShape?: ((x_timeseries: undefined | NestedArray<any>) => Shape)

Type declaration

    • (x_timeseries: undefined | NestedArray<any>): Shape
    • Parameters

      • x_timeseries: undefined | NestedArray<any>

      Returns Shape

layers?: TensorScriptLayers | TensorScriptSavedLayers
loss?: number
model: any
reshape: ((...args: any[]) => any)

Type declaration

    • (...args: any[]): any
    • Parameters

      • Rest ...args: any[]

      Returns any

settings: TensorScriptOptions
tf: any
tokenizer: any
trained: boolean
type: string
xShape?: number[]
yShape?: number[]

Methods

  • calculate(input_array: InputTextArray, options?: {}): any
  • Calculates sentence embeddings

    Returns

    returns tensorflow prediction

    Parameters

    • input_array: InputTextArray

      new test independent variables

    • options: {} = {}

      model prediction options

      Returns any

    • exportConfiguration(): TensorScriptContext
    • importConfiguration(configuration: TensorScriptContext): void
    • loadModel(options: string): Promise<any>
    • predict(input_array: InputTextArray, options?: PredictionOptions): Promise<Matrix | Vector>
    • Returns prediction values from tensorflow model

      Returns

      predicted model values

      Parameters

      • input_array: InputTextArray
      • options: PredictionOptions = {}

      Returns Promise<Matrix | Vector>

    • saveModel(options: string): Promise<any>
    • train(): Promise<any>
    • Asynchronously loads Universal Sentence Encoder and tokenizer

      Returns

      returns loaded UniversalSentenceEncoder model

      Returns Promise<any>

    • getInputShape(matrix?: any): Shape
    • Returns the shape of an input matrix

      Function

      Example

      const input = [
      [ 0, 1, ],
      [ 1, 0, ],
      ];
      TensorScriptModelInterface.getInputShape(input) // => [2,2]

      See

      Returns

      returns the shape of a matrix (e.g. [2,2])

      Parameters

      • matrix: any = []

        input matrix

      Returns Shape

    • reshape(array: Vector, shape: Shape): Matrix | Vector
    • Reshapes an array

      Function

      Example

      const array = [ 0, 1, 1, 0, ];
      const shape = [2,2];
      TensorScriptModelInterface.reshape(array,shape) // =>
      [
      [ 0, 1, ],
      [ 1, 0, ],
      ];

      Returns

      returns a matrix with the defined shape

      Parameters

      • array: Vector

        input array

      • shape: Shape

        shape array

      Returns Matrix | Vector