コード例 #1
0
function residual(x, params) {
    var out = convLayer_1.conv(x, params.conv1);
    out = convLayer_1.convNoRelu(out, params.conv2);
    out = tf.add(out, x);
    out = tf.relu(out);
    return out;
}
コード例 #2
0
ファイル: convLayer.js プロジェクト: BakirDiyar/face-api.js
function convLayer(x, params, strides, withRelu, padding) {
    if (padding === void 0) { padding = 'same'; }
    var _a = params.conv, filters = _a.filters, bias = _a.bias;
    var out = tf.conv2d(x, filters, strides, padding);
    out = tf.add(out, bias);
    out = scaleLayer_1.scale(out, params.scale);
    return withRelu ? tf.relu(out) : out;
}
コード例 #3
0
function residualDown(x, params) {
    var out = convLayer_1.convDown(x, params.conv1);
    out = convLayer_1.convNoRelu(out, params.conv2);
    var pooled = tf.avgPool(x, 2, 2, 'valid');
    var zeros = tf.zeros(pooled.shape);
    var isPad = pooled.shape[3] !== out.shape[3];
    var isAdjustShape = pooled.shape[1] !== out.shape[1] || pooled.shape[2] !== out.shape[2];
    if (isAdjustShape) {
        var padShapeX = out.shape.slice();
        padShapeX[1] = 1;
        var zerosW = tf.zeros(padShapeX);
        out = tf.concat([out, zerosW], 1);
        var padShapeY = out.shape.slice();
        padShapeY[2] = 1;
        var zerosH = tf.zeros(padShapeY);
        out = tf.concat([out, zerosH], 2);
    }
    pooled = isPad ? tf.concat([pooled, zeros], 3) : pooled;
    out = tf.add(pooled, out);
    out = tf.relu(out);
    return out;
}
コード例 #4
0
ファイル: tfjs_backend.js プロジェクト: rehlotus/assignments
function relu(x) {
    return tfc.relu(x);
}