I am using a few layers on top of VGG16, to tune the net for recognizing only if there is or not a specific object on an image.
const outputLayer = tf.layers
.dense({ units: 1, activation: "sigmoid", dtype: "float32" })
.apply(dense2);
const detection = tf.model({
inputs: baseModel.inputs,
outputs: outputLayer as tf.SymbolicTensor[],
});
detection.compile({
optimizer: tf.train.adam(0.0001), //could be a parameter as well.
loss: tf.losses.sigmoidCrossEntropy,
metrics: ["mse"],
});
The output is [0,1]
when I do a prediction. Why isn’t the output a single number, when the last layer has a single unit ?
Just in case this helps to solve, the labels have this format:
[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1,
... more items
]