I’m trying to use a convolutional auto-encoder to reconstruct some vectors (not images).
In order to assess whether it’s working I’d like to plot the cosine similarity between the input data and the reconstructed vector. What I’m doing right now is this:
model.eval()
    with torch.no_grad():
        for data in loader_val: # Validation dataset
            # CAE
            data, noise = data # Use data w/ noise as input model
            data = data.unsqueeze(1).float()
            noise = noise.unsqueeze(1).float()
            
            out = model(noise)
            loss = criterion(out, data)
            
            # Cosine similarity
            cos = CosineSimilarity()
            cosine_sims.append(cos(data, out))

I wanted to visually see how it changes after each epoch and so I used the following commands to plot it:
plt.plot([np.mean(np.abs(el.numpy())) for el in cosine_sims])

The problem is that the values start at 0.9 and they just fluctuate (not decreasing or increasing). Is there something wrong in the way I use CosineSimilarity?