TensorScriptModelInterface
Base class for tensorscript models
Static Method Summary
Static Public Methods | ||
public static |
getInputShape(matrix: Array<Array<number>>): Array<number> Returns the shape of an input matrix |
|
public static |
reshape(array: Array<number>, shape: Array<number>): Array<Array<number>> Reshapes an array |
Constructor Summary
Public Constructor | ||
public |
constructor(options: Object, customTF: Object, properties: *) |
Member Summary
Public Members | ||
public |
getInputShape: Function |
|
public |
model: Object |
|
public |
reshape: Function |
|
public |
settings: Object |
|
public |
tf: Object |
Method Summary
Public Methods | ||
public abstract |
calculate(matrix: Array<Array<number>>|Array<number>): {data: Promise} Predicts new dependent variables |
|
public |
async loadModel(options: Object): Object Loads a saved tensoflow / keras model |
|
public |
async predict(input_matrix: Array<Array<number>>|Array<number>): Array<number>|Array<Array<number>> Returns prediction values from tensorflow model |
|
public abstract |
train(x_matrix: Array<Array<number>>, y_matrix: Array<Array<number>>): Object Asynchronously trains tensorflow model, must be implemented by tensorscript class |
Static Public Methods
public static getInputShape(matrix: Array<Array<number>>): Array<number> source
Returns the shape of an input matrix
Params:
Name | Type | Attribute | Description |
matrix | Array<Array<number>> | input matrix |
Return:
Array<number> | returns the shape of a matrix (e.g. [2,2]) |
Example:
const input = [
[ 0, 1, ],
[ 1, 0, ],
];
TensorScriptModelInterface.getInputShape(input) // => [2,2]
public static reshape(array: Array<number>, shape: Array<number>): Array<Array<number>> source
Reshapes an array
Params:
Name | Type | Attribute | Description |
array | Array<number> | input array |
|
shape | Array<number> | shape array |
Return:
Array<Array<number>> | returns a matrix with the defined shape |
Example:
const array = [ 0, 1, 1, 0, ];
const shape = [2,2];
TensorScriptModelInterface.reshape(array,shape) // =>
[
[ 0, 1, ],
[ 1, 0, ],
];
Public Constructors
public constructor(options: Object, customTF: Object, properties: *) source
Params:
Name | Type | Attribute | Description |
options | Object | tensorflow model hyperparameters |
|
customTF | Object | custom, overridale tensorflow / tensorflow-node / tensorflow-node-gpu |
|
properties | * | extra instance properties |
Public Members
public getInputShape: Function source
public model: Object source
public reshape: Function source
public settings: Object source
public tf: Object source
Public Methods
public abstract calculate(matrix: Array<Array<number>>|Array<number>): {data: Promise} source
Predicts new dependent variables
Params:
Name | Type | Attribute | Description |
matrix | Array<Array<number>>|Array<number> | new test independent variables |
Return:
{data: Promise} | returns tensorflow prediction |
public async loadModel(options: Object): Object source
Loads a saved tensoflow / keras model
Params:
Name | Type | Attribute | Description |
options | Object | tensorflow load model options |
Return:
Object | tensorflow model |
public async predict(input_matrix: Array<Array<number>>|Array<number>): Array<number>|Array<Array<number>> source
Returns prediction values from tensorflow model
Params:
Name | Type | Attribute | Description |
input_matrix | Array<Array<number>>|Array<number> | new test independent variables |
|
options.json | Boolean |
|
return object instead of typed array |
options.probability | Boolean |
|
return real values instead of integers |
Return:
Array<number>|Array<Array<number>> | predicted model values |
public abstract train(x_matrix: Array<Array<number>>, y_matrix: Array<Array<number>>): Object source
Asynchronously trains tensorflow model, must be implemented by tensorscript class
Params:
Name | Type | Attribute | Description |
x_matrix | Array<Array<number>> | independent variables |
|
y_matrix | Array<Array<number>> | dependent variables |
Return:
Object | returns trained tensorflow model |