Learning Generative Models of Similarity Matrices