Unfortunately I still cannot figure it out, but here are some problems that may lead to this:



 a_d:

encoded, out = model(x)
    encoded = encoded.squeeze().detach().numpy()
...
    train_numpy.append(x)  # should not be `train_numpy.append(encoded)` ??



You have never used encoded. I think you probably is passing x instead of encoded to the train_numpy.append(x)? I think because of these, x has same structure as y and needs .detach().numpy() but you have done these on encoded but never passed it to train_numpy.