2020-08-20 02:05:34 +02:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
exports.denseBlock4 = exports.denseBlock3 = void 0;
|
|
|
|
const tf = require("@tensorflow/tfjs-core");
|
|
|
|
const depthwiseSeparableConv_1 = require("../common/depthwiseSeparableConv");
|
|
|
|
function denseBlock3(x, denseBlockParams, isFirstLayer = false) {
|
2020-08-18 14:04:33 +02:00
|
|
|
return tf.tidy(() => {
|
|
|
|
const out1 = tf.relu(isFirstLayer
|
|
|
|
? tf.add(tf.conv2d(x, denseBlockParams.conv0.filters, [2, 2], 'same'), denseBlockParams.conv0.bias)
|
2020-08-20 02:05:34 +02:00
|
|
|
: depthwiseSeparableConv_1.depthwiseSeparableConv(x, denseBlockParams.conv0, [2, 2]));
|
|
|
|
const out2 = depthwiseSeparableConv_1.depthwiseSeparableConv(out1, denseBlockParams.conv1, [1, 1]);
|
2020-08-18 14:04:33 +02:00
|
|
|
const in3 = tf.relu(tf.add(out1, out2));
|
2020-08-20 02:05:34 +02:00
|
|
|
const out3 = depthwiseSeparableConv_1.depthwiseSeparableConv(in3, denseBlockParams.conv2, [1, 1]);
|
2020-08-18 14:04:33 +02:00
|
|
|
return tf.relu(tf.add(out1, tf.add(out2, out3)));
|
|
|
|
});
|
|
|
|
}
|
2020-08-20 02:05:34 +02:00
|
|
|
exports.denseBlock3 = denseBlock3;
|
|
|
|
function denseBlock4(x, denseBlockParams, isFirstLayer = false, isScaleDown = true) {
|
2020-08-18 14:04:33 +02:00
|
|
|
return tf.tidy(() => {
|
|
|
|
const out1 = tf.relu(isFirstLayer
|
|
|
|
? tf.add(tf.conv2d(x, denseBlockParams.conv0.filters, isScaleDown ? [2, 2] : [1, 1], 'same'), denseBlockParams.conv0.bias)
|
2020-08-20 02:05:34 +02:00
|
|
|
: depthwiseSeparableConv_1.depthwiseSeparableConv(x, denseBlockParams.conv0, isScaleDown ? [2, 2] : [1, 1]));
|
|
|
|
const out2 = depthwiseSeparableConv_1.depthwiseSeparableConv(out1, denseBlockParams.conv1, [1, 1]);
|
2020-08-18 14:04:33 +02:00
|
|
|
const in3 = tf.relu(tf.add(out1, out2));
|
2020-08-20 02:05:34 +02:00
|
|
|
const out3 = depthwiseSeparableConv_1.depthwiseSeparableConv(in3, denseBlockParams.conv2, [1, 1]);
|
2020-08-18 14:04:33 +02:00
|
|
|
const in4 = tf.relu(tf.add(out1, tf.add(out2, out3)));
|
2020-08-20 02:05:34 +02:00
|
|
|
const out4 = depthwiseSeparableConv_1.depthwiseSeparableConv(in4, denseBlockParams.conv3, [1, 1]);
|
2020-08-18 14:04:33 +02:00
|
|
|
return tf.relu(tf.add(out1, tf.add(out2, tf.add(out3, out4))));
|
|
|
|
});
|
|
|
|
}
|
2020-08-20 02:05:34 +02:00
|
|
|
exports.denseBlock4 = denseBlock4;
|
2020-08-18 14:04:33 +02:00
|
|
|
//# sourceMappingURL=denseBlock.js.map
|