TensorSpace.js
Getting Start
Basic Concepts
Model Preprocessing
Models
Layers
Merge Function
Pooling1d
1D pooling. MaxPooling1d and AveragePooling1d only change the calculate method not the structure of the model, so they both use this API.
Constructor
Two methods to create a new layer. Arguments are required.
〔Method 1〕Use poolSize and strides
TSP.layers.Pooling1d( { poolSize : Int, strides: Int } );
〔Method 2〕Use shape
TSP.layers.Pooling1d( { shape : [ Int, Int ] } );
Fig. 1 - Pooling1d layer collapse and expand
Arguments

Name

Tag

Type

Instruction

Usage Notes and Examples

poolSize

📦

Int Shape of pooling windows poolSize: 2, Width is 2

strides

📦

Int The strides of the pooling windows strides = 1, Transverse step 1

name

🔧

String Name of this layer. Highly recommend to arrange to make code more readable. name: "layerName"

padding

🔧📦

String Is padding?

valid(default) Without padding. It drops the right-most columns (or bottom-most rows).

same With padding. Output size is the same as input size.

shape

⚙️📦

Int[] Output shape shape = [ 28 ].

color

⚙️🎨

color format Color of layer Pooling1d default is light blue #00ffff

closeButton

⚙️🎨

Dict Close button appearance control dict, more about close button

display : Boolean. true[default] Show button, false Hide button

ratio : Int. Times to normal size, default is 1

For example, 2 means twice the normal size

initStatus

⚙️️🎦

String Layer status at beginning. Open or Close close[default] : Closed at beginning

animation-
TimeRatio

⚙️🎦

Int The speed of open and close animation Integer for multiple of speed. For example, 2 for 2 times of basic speed.
Properties
.inputShape : Int[]
filter_center_focusThe shape of input tensor, for example inputShape = [ 28, 2 ] represents 2 feature vectors and length of each one is 28.
filter_center_focusAfter model.init() data is available, otherwise is undefined.
.outputShape : Int[]
filter_center_focusThe shape of output tensor is 2-dimensional. 2️⃣
filter_center_focusdataFormat is channel last. for example outputShape = [ 32, 4 ] represents the output through this layer has 4 feature vectors and length of each one is 32.
filter_center_focusAfter model.init() data is available, otherwise is undefined.
.neuralValue : Int[]
filter_center_focusThe intermediate raw data after this layer.
filter_center_focusAfter load and model.predict() data is available, otherwise is undefined.
.name : String
filter_center_focusThe custom name for this layer.
filter_center_focusOnce created, you can get it.
.layerType : String
filter_center_focusType of this layer, return a constant: string Pooling1d.
filter_center_focusOnce created, you can get it.
Method
filter_center_focusThis method only used in Functional Model (Non-sequential, Graph structure).
filter_center_focusLink this layer to layer which is the previous layer.
filter_center_focusTo crete a link between this layer and the previous layer. You don't need to use this method specifically to create links in Sequential Model; Instead, you can simply add layers along the lines of Keras or TensorFlow.js build the model syntax.
let convLayer = new TSP.layers.Conv1d( {

    kernelSize: 2,
    filters: 16,
    strides: 1

} );

let poolingLayer = new TSP.layers.Pooling1d( {

    poolingSize: 2,
    strides: 2

} );

poolingLayer.apply( convLayer );
filter_center_focusClick on the layer directly to open it by interacting directly with the object in the 3D scene.
filter_center_focusIn code, calling the method to open it.
let poolingLayer = new TSP.layers.Pooling1d( {

    // configure some parameters for Pooling1d.

} );

model.add( poolingLayer );

// ... add more layers for model.

model.init();

// Call openLayer API to open layer.

poolingLayer.openLayer();
filter_center_focusTo close by interacting directly with objects in a 3D scene by clicking the close button.
filter_center_focus In code, calling the method to close it.
let poolingLayer = new TSP.layers.Pooling1d( {

    // configure some parameters for Pooling1d.

} );

model.add( poolingLayer );

// ... add more layers for model.

model.init();

// If this layer already opened, call closeLayer API to close layer.

poolingLayer.closeLayer();
Example
filter_center_focus Declare an instance of Pooling1d to facilitate reuse
let poolingLayer = new TSP.layers.Pooling1d( {

    poolingSize: 2,
    strides: 2,
    animationTimeRatio: 2,
    name: "Pooling1d1",
    initStatus: "open"

} );

model.add( poolingLayer );
filter_center_focusAdd Pooling1d directly
model.add(new TSP.layers.Pooling1d( {

    poolingSize: 2,
    strides: 2,
    name: "Pooling1d2"

} ));
Use Case
When you add pooling layer with Keras | TensorFlow | tfjs in your model the corresponding API is Pooling1d in TensorSpace.
Framework Documentation
Keras keras.layers.MaxPooling1D(pool_size=2, strides=None)
TensorFlow tf.layers.max_pooling1d( inputs, pool_size, strides)
TensorFlow.js tf.layers.maxPooling1d (config)
Tag Lookup
Tag Icon Meaning Instruction
⭐️ Required Must be provided, cannot be empty. Meanwhile constructor works properly if this arguments provided. Control arguments use default value.
🔧 Suggest Recommended for giving. The API can work without them.
⚙️ Optional As an auxiliary adjustment parameter when used, selectively added according to the specific situation The parameters here have no effect on the structure of the layer (3D visualized form).
📦 Model Configure the properties of the Layer. It changes the output shape.
🎨 Style Override the properties in TSP.model (model configuration)
🎦 Animation Override the properties in TSP.model (model configuration)
Source Code
tensorspace/src/layer/intermediate/Pooling1d.js