5. Unsupervised clustering implementation in Keras
The network model implementation in Keras for unsupervised clustering is shown in Listing 13.5.1. Only the initialization is shown. The network hyperparameters are stored in args
. The VGG backbone object is supplied during initializations. Given a backbone, the model is actually just a Dense
layer with a softmax activation, as shown in the build_model()
method. There is an option to create multiple heads.
Similar to Chapter 11, Object Detection, we implemented a DataGenerator
class to efficiently serve input data in a multithreaded fashion. A DataGenerator
object generates the required paired train input data (that is, a Siamese input image) made of the input image X and its transformed image . The most critical method, __data_generation()
, of the DataGenerator
class is shown in Listing 13.5.2. The input image X is center cropped from the original input image. In the case of MNIST, this is 24 x 24-pixel center cropping...