Getting Start
Basic Concepts
TensorSpace Converter
Model Preprocessing
Merge Function
Sequential Model
Similar to Keras-style sequential model, Sequential() creates a model which is simply a stack of layers.
We can create a sequential model, like:
let seqModel = new TSP.models.Sequential( container, {

    // optional configurations
    layerInitStatus: "close",
    aggregationStrategy: "max",
    layerShape: "rect",

} );
Then we can insert layers into the model by the designed order:
seqModel.add( new TSP.layers.GreyscaleInput( {

    name: "initInput",
    color: 0xFFFFFF,

} ) );

seqModel.add( new TSP.layers.Padding2d() );

let convLayer = new TSP.layers.Conv2d( {

    name: "conv2d1",

} );
seqModel.add( convLayer );
We can add the layer either as a claimed layer or as an anonymous layer.
After creating the structure of the model, we can load() the pre-trained ML model and init() to create the layer objects:
seqModel.load( {

    type: "tensorflow",
    url: 'model.json',

    onProgress: function( fraction ) {

        console.log( "Loading progress: " + fraction );


    onComplete: function() {

        console.log( "Complete load model." );


} );

seqModel.init( function() {

    console.log("TensorSpace's Model is initialized!");

} );
predict() method handles the prediction process for all layers including the hidden layers.
  • filter_center_focus Represents the strategy of computing data used to render layer aggregation.
.layerShape : String
  • filter_center_focus Represents the layout of expanded feature maps of a layer.
  • filter_center_focus Represents the initial status of an expandable layer. Either "expanded" as feature maps or "collapsed" as an aggregation.
.textSystem : String
  • filter_center_focus Enable or disable the display text information of each layers.
  • filter_center_focus Enable or disable the display of relation lines among layers.
.animeTime : Double
  • filter_center_focus Time spent for animation.
.color : Color Format
  • filter_center_focus All necessary color configurations of different layers and the background.
.stats : Bool
  • filter_center_focus Whether to use stats utility or not.
  • filter_center_focus Configure input shapes for pre-trained model if pre-trained model's input shape is dynamical.
.feedInputs : Array
  • filter_center_focus Configure which inputs of pre-trained model to be applied into TensorSpace model's input.
  • filter_center_focus The init( complete_callback ) method use the provided configurations to create the actual objects of the model.
  • filter_center_focus See Model (concept) for more details.
  • filter_center_focus The load() method is used to maintain the pre-trained ML model (from TensorFlow, Keras or TensorFlow.js).
  • filter_center_focus See Load for more details.
  • filter_center_focus The predict() method uses the provided input data and the loaded ML model to compute all necessary predictions including the intermediate outputs and final inferences for rendering visualization objects.
  • filter_center_focus See Predict for more details.
.reset() : void
  • filter_center_focus The reset() method is used to set the model back to its initialization status.
  • filter_center_focus The camera will be moved to its initialized position. The view angle will be changed to initial default angle.
  • filter_center_focus All existing prediction data in each layer object will be cleaned up. All visualizing objects will be re-rendered without any data.
  • filter_center_focus The add() method is used to append the provided TSP layer object into the TSP Sequential model.
  • filter_center_focus The provided layer is added to the last of the sequential list of the model.
  • filter_center_focus The provided layer instance will be updated based on the Sequential model configurations.
.getAllLayers() : Layer[]
  • filter_center_focus To get all layer objects within the model.
  • filter_center_focus To get a specified layer object by its name (String).
We can try the examples above in the CodePen below:

See the Pen TensorSpace - Sequential by syt123450 (@syt123450) on CodePen.