Text Embedding with Tensorflow Universal Sentence Encoder (USE)

implements

  {TensorScriptModelInterface}

### Hierarchy

- TensorScriptModelInterface
  - TextEmbedding

## Index

### Constructors

- constructor

### Properties

- compiled
- getInputShape
- getTimeseriesShape
- layers
- loss
- model
- reshape
- settings
- tf
- tokenizer
- trained
- type
- xShape
- yShape

### Methods

- calculate
- exportConfiguration
- importConfiguration
- loadModel
- predict
- saveModel
- train
- getInputShape
- reshape

## Constructors

### constructor

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

- Overrides TensorScriptModelInterface.constructor

  - Defined in src/text_embedding.ts:12

  #### Parameters

  - ##### Default value options: TensorScriptOptions = {}

    Options for USE

  - ##### Optional properties: TensorScriptProperties

    extra instance properties

  #### Returns TextEmbedding

## Properties

### compiled

compiled: boolean

Inherited from TensorScriptModelInterface.compiled

- Defined in src/model_interface.ts:220

### getInputShape

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

Inherited from TensorScriptModelInterface.getInputShape

- Defined in src/model_interface.ts:222

#### Type declaration

- - (...args: any[]): any

  - #### Parameters

    - ##### Rest ...args: any[]

    #### Returns any

### Optional getTimeseriesShape

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

Inherited from TensorScriptModelInterface.getTimeseriesShape

- Defined in src/model_interface.ts:226

### Optional layers

layers: TensorScriptLayers | TensorScriptSavedLayers

Inherited from TensorScriptModelInterface.layers

- Defined in src/model_interface.ts:225

### Optional loss

loss: undefined | number

Inherited from TensorScriptModelInterface.loss

- Defined in src/model_interface.ts:227

### model

model: any

Inherited from TensorScriptModelInterface.model

- Defined in src/model_interface.ts:216

### reshape

reshape: (...args: any[]) => any

Inherited from TensorScriptModelInterface.reshape

- Defined in src/model_interface.ts:221

#### Type declaration

- - (...args: any[]): any

  - #### Parameters

    - ##### Rest ...args: any[]

    #### Returns any

### settings

settings: TensorScriptOptions

Inherited from TensorScriptModelInterface.settings

- Defined in src/model_interface.ts:215

### tf

tf: any

Inherited from TensorScriptModelInterface.tf

- Defined in src/model_interface.ts:218

### tokenizer

tokenizer: any

Inherited from TensorScriptModelInterface.tokenizer

- Defined in src/model_interface.ts:217

### trained

trained: boolean

Inherited from TensorScriptModelInterface.trained

- Defined in src/model_interface.ts:219

### type

type: string

Inherited from TensorScriptModelInterface.type

- Defined in src/model_interface.ts:214

### Optional xShape

xShape: number[]

Inherited from TensorScriptModelInterface.xShape

- Defined in src/model_interface.ts:223

### Optional yShape

yShape: number[]

Inherited from TensorScriptModelInterface.yShape

- Defined in src/model_interface.ts:224

## Methods

### calculate

- calculate(input_array: InputTextArray, options?: {}): any

- Overrides TensorScriptModelInterface.calculate

  - Defined in src/text_embedding.ts:53

  Calculates sentence embeddings

  override

  #### Parameters

  - ##### input_array: InputTextArray

    new test independent variables

  - ##### Default value options: {} = {}

    model prediction options

  #### Returns any

  returns tensorflow prediction

### exportConfiguration

- exportConfiguration(): TensorScriptContext

- Inherited from TensorScriptModelInterface.exportConfiguration

  - Defined in src/model_interface.ts:352

  #### Returns TensorScriptContext

### importConfiguration

- importConfiguration(configuration: TensorScriptContext): void

- Inherited from TensorScriptModelInterface.importConfiguration

  - Defined in src/model_interface.ts:363

  #### Parameters

  - ##### configuration: TensorScriptContext

  #### Returns void

### loadModel

- loadModel(options: string): Promise<any>

- Inherited from TensorScriptModelInterface.loadModel

  - Defined in src/model_interface.ts:402

  Loads a saved tensoflow / keras model, this is an alias for

  see

    https://www.tensorflow.org/js/guide/save_load#loading_a_tfmodel

  #### Parameters

  - ##### options: string

    tensorflow load model options

  #### Returns Promise<any>

  tensorflow model

### predict

- predict(input_array: InputTextArray, options?: PredictionOptions): Promise<Matrix | Vector>

- Overrides TensorScriptModelInterface.predict

  - Defined in src/text_embedding.ts:65

  Returns prediction values from tensorflow model

  #### Parameters

  - ##### input_array: InputTextArray

  - ##### Default value options: PredictionOptions = {}

  #### Returns Promise<Matrix | Vector>

  predicted model values

### saveModel

- saveModel(options: string): Promise<any>

- Inherited from TensorScriptModelInterface.saveModel

  - Defined in src/model_interface.ts:415

  saves a tensorflow model, this is an alias for

  see

    https://www.tensorflow.org/js/guide/save_load#save_a_tfmodel

  #### Parameters

  - ##### options: string

    tensorflow save model options

  #### Returns Promise<any>

  tensorflow model

### train

- train(): Promise<any>

- Overrides TensorScriptModelInterface.train

  - Defined in src/text_embedding.ts:30

  Asynchronously loads Universal Sentence Encoder and tokenizer

  override

  #### Returns Promise<any>

  returns loaded UniversalSentenceEncoder model

### Static getInputShape

- getInputShape(matrix?: any): Shape

- Inherited from TensorScriptModelInterface.getInputShape

  - Defined in src/model_interface.ts:333

  Returns the shape of an input matrix

  function
  example

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

  see

    {https://stackoverflow.com/questions/10237615/get-size-of-dimensions-in-array}

  #### Parameters

  - ##### Default value matrix: any = []

    input matrix

  #### Returns Shape

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

### Static reshape

- reshape(array: Vector, shape: Shape): Matrix | Vector

- Inherited from TensorScriptModelInterface.reshape

  - Defined in src/model_interface.ts:268

  Reshapes an array

  function
  example

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

  #### Parameters

  - ##### array: Vector

    input array

  - ##### shape: Shape

    shape array

  #### Returns Matrix | Vector

  returns a matrix with the defined shape