I want to implement a prototypical network (https://arxiv.org/pdf/1703.05175.pdf) with keras (there are some implementations in pytorch and tensorflow, but those are not ideal for me).
This NN is used for few-shot learning and the algorithm works in the way that it chooses several observations of various classes which are embedded through a certain function, centroids of these classes are calculated and a loss function based on the distance of some other embedded observations from the centroids is calculated. The embedding function is then optimizied (= 1 episode) and the process repeats. After all the train data have been used, a new epoch starts.
It is not clear to me whether this can be reasonably implemented with keras and, if so, what would be the best way to do it. Could anybody give me a hand on how to insert such episodes into an epoch, or recommend me a good source?
For a reference, see the tensorflow implementation https://github.com/kvpratama/prototypical-networks-tensorflow
Thank you very much in advance.