Currently I am extending a the Neural Network VGG16 (I implemented it in Typescript) using this code:
/* Create the Bounding Box Model, using a regression head on top of VGG16. */
// Layer 19: Flatten
const flat = tf.layers.flatten().apply(baseModel.inputs);
// Layer 20: Fully Connected Layer
const dense1 = tf.layers.dense({ units: 128, activation: "relu" }).apply(flat);
// Layer 21: Fully Connected Layer
const dense2 = tf.layers.dense({ units: 32, activation: "relu" }).apply(dense1);
// Layer 22: Sigmoid Layer (sigmoid ranges bw 0 and 1)
const outputLayer = tf.layers
.dense({ units: 4, activation: "sigmoid" })
.apply(dense2);
const vggBBox = tf.model({
inputs: baseModel.inputs,
outputs: outputLayer as tf.SymbolicTensor[],
});
However, I find this way of writing quite cumbersome. Is tf.model the only way to extend the network, or is it possible to either append/push layers to a sequential.layers array, or any other approach ?
is that inputs is not trainable, as I set it with trainable = false; however, I do not see a way to do it in layers, would just tf.models.layers.push([prevPrevOutLay, prevOutLay, outLay]) be reasonable choice ?