import * as tf from
"@tensorflow/tfjs"
;
const Input = tf.input({ shape: [2, 2, 3] });
const globalAveragePooling2d =
tf.layers.globalAveragePooling2d({
dataFormat:
'channelsLast'
,
batchInputShape: [4, 3, 3],
trainable:
true
});
const Output = globalAveragePooling2d.apply(Input);
const model = tf.model({ inputs: Input, outputs: Output });
const Data = tf.tensor4d([8, 2, 2, 6, 8, 9, 9,
4, 8, 9, 3, 8, 5, 2, 5, 2, 8, 6, 4, 5, 9,
12, 8, 11], [2, 2 ,2, 3]);
model.predict(Data).print();