jemisjoky / TorchMPS

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

Adaptive mode for MPS #16

Closed MASFLJY closed 3 years ago

MASFLJY commented 3 years ago

Hi, I am quite new to Pytorch, please bear with me if this turned out to be a stupid question.

I tried to run the train_script.py with adaptive_mode = True without touching most of the other example codes. But I kept getting the following error messages

raceback (most recent call last): File "train_script.py", line 82, in scores = mps(inputs) File "/home/yl/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, **kwargs) File "/mnt/c/users/user/desktop/TNMachineLearning/TorchMPS/torchmps/torchmps.py", line 490, in forward assert new_svs[i] != -1 RuntimeError: Boolean value of Tensor with more than one value is ambiguous

I tried changing the Merge_threshold, it seems the message will pop up either in the first loop epoch or even the second depending on the threshold value. Do I need to change anything else to run the adaptive mode?

Edit: Another quick question is, is there going to be an implementation of a non-local feature map?

Thanks a lot. Leo

MASFLJY commented 3 years ago

okay, there could be a bug. It might be due to the comparison between torch.tensor with -1. I changed it and it works.

jemisjoky commented 3 years ago

Thank you for letting me know, that does look like a silly bug! I'll check that out in the next few days and work on getting a fix in.

jemisjoky commented 3 years ago

I just changed the code to fix the issue you pointed out, and the training script is now running correctly in adaptive mode on my machine. I'm going to close this issue in a bit, but let me know if you still encounter issues when running the training script with the newest version of the code. (BTW I moved the location of train_script.py, so you can now find it in the main directory)

jemisjoky commented 3 years ago

@MASFLJY, sorry for missing your question earlier! I don't have any plans at present to implement a non-local feature map, but will let you know if I do so in the future. Thanks again for your interest in TorchMPS, and please let me know if you find any more bugs!