I want to train some models on different classes of a dataset such that each model has only relevant number of nodes in output layer. Later on, i want to combine their learning by making one common vector, say, aggregation of their outputs. and the final/aggregation model would learn from this aggregated output vector.
For instance, for Cifar 10 dataset,I have two models; Model-1 and Model-2.
Model-1 has samples of only classes 1,3,5,7 and Model-2 has samples of, say, 0,3,5,8,9. Here as it is clear that model1 has samples of only 4 classes so it should have only 4 nodes in output layer. Similarly, Model-2 has samples of 5 classes so it should have 5 nodes in output layer.
As per my understanding;
the actual number of classes in cifar 10 dataset : [0,1,2,3,4,5,6,7,8,9]
classes for Model-1 : [1,3,5,7]
classes for Model-2 : [0,3,5,8,9]
I simply made two models with relevant number of nodes. But, when i try to apply one hot encoding for Model-1 using keras.utils.np_utils.to_categorical(y,num_classes=4), it does not allow me to do so and it gives the following error:
InvalidArgumentError: logits and labels must be broadcastable: logits_size=[32,4] labels_size=[32,7]
i further explored the internet and found that it is due to difference in label and class size i.e. Model-1 has max. class label as 7 so it means one hot encoding expects num_classes as 7 not 4. But, as per requirements, i have to follow same settings i.e. only relevant number of nodes should be in output layer of a model.
Any suggestion would be appreciated.