Learned Pattern Similarity and Representation for Time Series