In NodeJs, I try a standard sequential model for pictures classification:
this.model = tf.sequential();
this.kernel_size = [3, 3]
this.first_filters = 32
this.model.add( tf.layers.conv2d( {
inputShape: [modelImageHeight, modelImageWidth , modelImageChannels],
filters: this.first_filters,
kernelSize: this.kernel_size,
activation: 'relu',
}));
this.model.add( tf.layers.maxPooling2d( {poolSize: [2, 2] } ));
this.model.add( tf.layers.conv2d( { filters: 64, kernelSize: [2, 2], activation: 'relu'} ));
this.model.add( tf.layers.maxPooling2d( {poolSize: [2, 2] } ));
this.model.add( tf.layers.conv2d( { filters: 64, kernelSize: [2, 2], activation: 'relu'} ));
this.model.add(tf.layers.flatten());
this.model.add(tf.layers.dense( { units: 64, activation: 'relu' } ));
this.model.add(tf.layers.dense( { units: this.categoryCount, activation:'softmax' }));
In my dataset, I have only two categories/classes.
I want the model to predict one of the two class, or “unknown” if not one of these class.
Actually, with a picture of none of the both classes, the model answers a score equal to 1.0 with one of the both classes.
How to return a very low score, or a “unknown” class ?
Best regards.