This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 23
Layer Object
Matias Vazquez-Levi edited this page Jan 12, 2021
·
15 revisions
When you create a pooling layer you need to specify the number of input size, the sample size & the stride.
- type
A string representing the type of this layer.
- subtype
A string representing the sub type of this layer.
- sampleSize
The size of the 2d sample iterating trough the array.
- stride
The number of jumps the sample is going to perform for each iteration.
- pickFunc
The function this pooling layer uses to process a sample as an array into a numeric output. ex: avgpool, maxpool. See available pooling functions Here.
This function feeds data through the layer to obtain an output.
- input
Takes an array of inputs to feed through the layer.
- options (optional)
An object including specific properties.
- returns
Returns an array of outputs
Here is how you would create a pooling layer & compute some 16 length array of data.
const Layer = require('dannjs').layer; //nodejs only
const l1 = new Layer('avgpool' , 16, 2, 2);
const input = [
4, 3, 1, 5,
1, 3, 4, 8,
4, 5, 4, 3,
6, 5, 9, 4
];
const output = l1.feed(input);
console.log(output);
// Output:
// [2.75, 4.5, 5, 5]
You can also use this layer for a non-squarable array by specifing width & height when constructing the layer.
const Layer = require('dannjs').layer; //nodejs only
const l1 = new Layer('avgpool' , 12, 2, 1, 4, 3);
const input = [
4, 3, 1, 5,
1, 3, 4, 8,
4, 5, 4, 3
];
const output = l1.feed(input);
console.log(output);
// Output:
// [2.75, 2.75, 4.5, 2.75, 4, 4.75]