jemisjoky / TorchMPS

PyTorch toolbox for matrix product state models
MIT License
138 stars 31 forks source link

Question about use_bias #10

Closed bnuliujing closed 4 years ago

bnuliujing commented 4 years ago

Hi @jemisjoky , I really appreciate your work! I have a question about the functionality of use_bias option in MPS.

In train_script.py, if I set MPS(input_dim=28**2, output_dim=10, …, use_bias=False), then the code didn’t work. I also tried to implement the MPS classifier in your TorchMPS way and the same problem occurred again. Why the torch.eye(bond_dim) bias matrix matters? Is it just a trick to implement the MPS classifier correctly in a autograd way or it is related to some key point of MPS/Tensor Networks?

Looking forward to your reply.

jemisjoky commented 4 years ago

Hi @bnuliujing, my apologies for the extremely slow reply! I've been overwhelmed with a lot of other professional responsibilities lately, and am a bit behind on maintaining TorchMPS :(

For your question, I unfortunately can't reproduce the behavior you're describing. Using the current train_script.py with the following new line leads to normal behavior on my computer:

mps = MPS(input_dim=28**2, output_dim=10, bond_dim=bond_dim, 
          adaptive_mode=adaptive_mode, periodic_bc=periodic_bc, use_bias=False)

Could you check to make sure you have the current version of TorchMPS, then send me your modified script? The implementation of bias matrices in TorchMPS is a bit of a mess, so I'd love a good reason to improve this part of the code.

I'm going to close this for now, but feel free to reopen whenever you have that information :)