Thank you for taking the time to read through my (way too long) post. I really appreciate it.
I actually had a breakthrough just before you posted, it turns out that I was comparing tensors of different shapes in my pytorch code.
I included the line x = x.view(-1,1,336) in my encoder, but my dataloader was feeding it a tensor shaped (-1,336), so it must have been comparing the two different tensors in my loss function. I’m amazed it let me do that without throwing out an error. Giving my dataloader a shape (-1,1,336) tensor recovered the clustering observed in my keras model.
Sorry to have wasted your time.