Base class for tensorscript models

interface

  TensorScriptModelInterface

property

  {Object} settings - tensorflow model hyperparameters

property

  {Object} model - tensorflow model

property

  {Object} tf - tensorflow / tensorflow-node / tensorflow-node-gpu

property

  {Function} reshape - static reshape array function

property

  {Function} getInputShape - static TensorScriptModelInterface

### Hierarchy

- TensorScriptModelInterface
  - BaseNeuralNetwork
  - 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 TensorScriptModelInterface(options?: TensorScriptOptions, properties?: TensorScriptProperties): TensorScriptModelInterface

- - Defined in src/model_interface.ts:227

  #### Parameters

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

    tensorflow model hyperparameters

  - ##### Default value properties: TensorScriptProperties = {}

    extra instance properties

  #### Returns TensorScriptModelInterface

## Properties

### compiled

compiled: boolean

- Defined in src/model_interface.ts:220

### getInputShape

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

- 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)

- Defined in src/model_interface.ts:226

### Optional layers

layers: TensorScriptLayers | TensorScriptSavedLayers

- Defined in src/model_interface.ts:225

### Optional loss

loss: undefined | number

- Defined in src/model_interface.ts:227

### model

model: any

- Defined in src/model_interface.ts:216

### reshape

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

- Defined in src/model_interface.ts:221

#### Type declaration

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

  - #### Parameters

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

    #### Returns any

### settings

settings: TensorScriptOptions

- Defined in src/model_interface.ts:215

### tf

tf: any

- Defined in src/model_interface.ts:218

### tokenizer

tokenizer: any

- Defined in src/model_interface.ts:217

### trained

trained: boolean

- Defined in src/model_interface.ts:219

### type

type: string

- Defined in src/model_interface.ts:214

### Optional xShape

xShape: number[]

- Defined in src/model_interface.ts:223

### Optional yShape

yShape: number[]

- Defined in src/model_interface.ts:224

## Methods

### calculate

- calculate(matrix: Matrix | Vector | InputTextArray): Calculation

- - Defined in src/model_interface.ts:393

  Predicts new dependent variables

  abstract

  #### Parameters

  - ##### matrix: Matrix | Vector | InputTextArray

    new test independent variables

  #### Returns Calculation

  returns tensorflow prediction

### exportConfiguration

- exportConfiguration(): TensorScriptContext

- - Defined in src/model_interface.ts:352

  #### Returns TensorScriptContext

### importConfiguration

- importConfiguration(configuration: TensorScriptContext): void

- - Defined in src/model_interface.ts:363

  #### Parameters

  - ##### configuration: TensorScriptContext

  #### Returns void

### loadModel

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

- - 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_matrix?: Matrix | Vector | InputTextArray | PredictionOptions, options?: PredictionOptions): Promise<any>

- - Defined in src/model_interface.ts:429

  Returns prediction values from tensorflow model

  #### Parameters

  - ##### Optional input_matrix: Matrix | Vector | InputTextArray | PredictionOptions

    new test independent variables

  - ##### Optional options: PredictionOptions

  #### Returns Promise<any>

  predicted model values

### saveModel

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

- - 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(x_matrix: Matrix, y_matrix?: Matrix, layers?: TensorScriptLayers, x_test?: Matrix, y_test?: Matrix): Promise<LayersModel>
- train(x_matrix: Matrix, y_matrix: Matrix): Promise<Matrix>

- - Defined in src/model_interface.ts:382

  Asynchronously trains tensorflow model, must be implemented by tensorscript class

  abstract

  #### Parameters

  - ##### x_matrix: Matrix

    independent variables

  - ##### Optional y_matrix: Matrix

    dependent variables

  - ##### Optional layers: TensorScriptLayers

  - ##### Optional x_test: Matrix

  - ##### Optional y_test: Matrix

  #### Returns Promise<LayersModel>

  returns trained tensorflow model

- - Defined in src/model_interface.ts:383

  #### Parameters

  - ##### x_matrix: Matrix

  - ##### y_matrix: Matrix

  #### Returns Promise<Matrix>

### Static getInputShape

- getInputShape(matrix?: any): Shape

- - 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

- - 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