F# Advent Calendar — A Christmas Classifier

I can’t post an image of the whole network here (it has 48 layers!) but for this task the relevant section is in the output layer of the network.Inception-v3 Softmax2 FunctionThe Softmax2 node in the image above is an activation function that takes the final representation of the image, in terms of the 1000 classes, and converts this into a probability distribution.It assigns a decimal probability to each class so we can determine which class is the most likely one for the image.In my image classifier I could use the Inception-v3 model by taking the input to the Softmax2 node (softmax2_pre_activation) and using this as the features of an image for an algorithm in ML.NET.The ML.NET ModelThe model is defined in Program.fsThe dataLoader specifies the schema of the input data.Input Data SchemaThe dataLoader is then used to load the training and test data views.Load Training and Test DataThe dataPipeline specifies the transforms that should be applied to the input tsv.Since this is a binary classification, I used a custom mapping to convert the two classes into Boolean values — santaclaus = true and notsantaclaus = false.Transform Input DataI then used the modelBuilder to describe the pipeline of how images are loaded, preprocessed and used to train the model.The pipeline loads the images using the relative paths defined in the input tsv, resizes them so they are all the same size and then extracts the pixel information so they can be passed into the Inception-v3 model.Image Loading and PreprocessingUsing the TensorFlowEstimator, the pipeline loads the pre trained Inception-v3 model and inputs the extracted pixels from the stage before.I wanted to use the input to the Softmax2 node to get my features for the algorithm I was going to use in ML.NET.. More details

Leave a Reply