UNPKG

@vladmandic/face-api

Version:

JavaScript module for Face Detection and Face Recognition Using Tensorflow/JS

19 lines (16 loc) 437 B
import * as tf from '@tensorflow/tfjs/dist/tf.es2017.js'; import { ConvParams } from './types'; export function convLayer( x: tf.Tensor4D, params: ConvParams, padding: 'valid' | 'same' = 'same', withRelu: boolean = false ): tf.Tensor4D { return tf.tidy(() => { const out = tf.add( tf.conv2d(x, params.filters, [1, 1], padding), params.bias ) as tf.Tensor4D return withRelu ? tf.relu(out) : out }) }