MCPcopy
hub / github.com/tensorflow/tfjs / constructor

Function constructor

tfjs-layers/src/layers/pooling.ts:161–202  ·  view source on GitHub ↗

* * @param args Parameters for the Pooling layer. * * config.poolSize defaults to 2.

(args: Pooling1DLayerArgs)

Source from the content-addressed store, hash-verified

159 * config.poolSize defaults to 2.
160 */
161 constructor(args: Pooling1DLayerArgs) {
162 if (args.poolSize == null) {
163 args.poolSize = 2;
164 }
165 super(args);
166 if (typeof args.poolSize === 'number') {
167 this.poolSize = [args.poolSize];
168 } else if (
169 Array.isArray(args.poolSize) &&
170 (args.poolSize as number[]).length === 1 &&
171 typeof (args.poolSize as number[])[0] === 'number') {
172 this.poolSize = args.poolSize;
173 } else {
174 throw new ValueError(
175 `poolSize for 1D convolutional layer must be a number or an ` +
176 `Array of a single number, but received ` +
177 `${JSON.stringify(args.poolSize)}`);
178 }
179 assertPositiveInteger(this.poolSize, 'poolSize');
180 if (args.strides == null) {
181 this.strides = this.poolSize;
182 } else {
183 if (typeof args.strides === 'number') {
184 this.strides = [args.strides];
185 } else if (
186 Array.isArray(args.strides) &&
187 (args.strides as number[]).length === 1 &&
188 typeof (args.strides as number[])[0] === 'number') {
189 this.strides = args.strides;
190 } else {
191 throw new ValueError(
192 `strides for 1D convolutional layer must be a number or an ` +
193 `Array of a single number, but received ` +
194 `${JSON.stringify(args.strides)}`);
195 }
196 }
197 assertPositiveInteger(this.strides, 'strides');
198
199 this.padding = args.padding == null ? 'valid' : args.padding;
200 checkPaddingMode(this.padding);
201 this.inputSpec = [new InputSpec({ndim: 3})];
202 }
203
204 override computeOutputShape(inputShape: Shape|Shape[]): Shape|Shape[] {
205 inputShape = getExactlyOneShape(inputShape);

Callers

nothing calls this directly

Calls 3

assertPositiveIntegerFunction · 0.90
checkPaddingModeFunction · 0.90
checkDataFormatFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…