Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpy int32 error #12

Closed
ACE07-Sev opened this issue Jun 6, 2022 · 4 comments
Closed

Numpy int32 error #12

ACE07-Sev opened this issue Jun 6, 2022 · 4 comments

Comments

@ACE07-Sev
Copy link
Contributor

Hi I ran the Quantum_trainer, and been getting this and can't seem to find where the issue is.

Traceback (most recent call last):
File "C:\Users\elmm\Desktop\CQM\QNLP Depression.py", line 103, in
trainer.fit(train_dataset, val_dataset, logging_step=12)
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\lambeq\training\trainer.py", line 365, in fit
y_hat, loss = self.training_step(batch)
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\lambeq\training\quantum_trainer.py", line 149, in training_step
y_hat, loss = self.optimizer.backward(batch)
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\lambeq\training\spsa_optimizer.py", line 125, in backward
y0 = self.model(diagrams)
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\lambeq\training\model.py", line 59, in call
return self.forward(*args, **kwds)
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\lambeq\training\tket_model.py", line 131, in forward
return self.get_diagram_output(x)
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\lambeq\training\tket_model.py", line 103, in get_diagram_output
seed=self._randint()
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\lambeq\training\tket_model.py", line 71, in _randint
return np.random.randint(low, high)
File "mtrand.pyx", line 746, in numpy.random.mtrand.RandomState.randint
File "_bounded_integers.pyx", line 1334, in numpy.random._bounded_integers._rand_int32
ValueError: low is out of bounds for int32

@Thommy257
Copy link
Contributor

Thommy257 commented Jun 6, 2022

Sorry, we are aware of the issue and it will be fixed in the next minor release. In the meantime, you can change the _randint() (line71-72) method in "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\lambeq\training\tket_model.py" to the following:

def _randint(self, low=-1 << 63, high=(1 << 63)-1):
    return np.random.randint(low, high, dtype=np.int64)

@ACE07-Sev
Copy link
Contributor Author

Thank you so much. Right now it is running (it's a bit slow so it's on epoch 120, and has to reach 1000), but I think this fixed the issue.

@Thommy257
Copy link
Contributor

This is to be expected for the TketModel. To debug your architecture we suggest to use the NumpyModel with jit support enabled (faster by an order of magnitude).

@dimkart
Copy link
Contributor

dimkart commented Jun 9, 2022

Sorry, we are aware of the issue and it will be fixed in the next minor release.

@ACE07-Sev Note that the new release is now out, including a fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants