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

TorchConnector returns two sets of weights in the state dict instead of one #785

Closed
MocanuPaulC opened this issue Mar 1, 2024 · 0 comments
Assignees
Labels
Connector: PyTorch 🔦 Relevant to optional packages, such as external connectors status: time-out Issuer creator has not responded within 2 weeks type: documentation 📖 Issues related to documentation type: question 🙋 Question about the code or its uses

Comments

@MocanuPaulC
Copy link

Environment

  • Qiskit Machine Learning version: 0.7.1
  • Python version: 3.10
  • Operating system: Ubuntu 22.04

What is happening?

When using TorchConnector on a SamplerQNN or EstimatorQNN, the state_dict() holds two sets of the same weights.

How can we reproduce the issue?

import torch
from qiskit_machine_learning.neural_networks import EstimatorQNN
from qiskit_machine_learning.connectors import TorchConnector
from qiskit import QuantumCircuit

qt=QuantumCircuit(1)
qt.rx(0.5,0)
qtest=TorchConnector(EstimatorQNN(circuit=qt, input_params=[], weight_params=[]))
test=torch.nn.Sequential(qtest)
print(test.state_dict())

Output:

OrderedDict([('0.weight', tensor([])), ('0._weights', tensor([]))])

What should happen?

Only one set of the weights should appear

Any suggestions?

No response

@edoaltamura edoaltamura added type: bug 🐞 Something isn't working Connector: PyTorch 🔦 Relevant to optional packages, such as external connectors labels Mar 8, 2024
@oscar-wallis oscar-wallis added type: question 🙋 Question about the code or its uses type: documentation 📖 Issues related to documentation and removed type: bug 🐞 Something isn't working labels May 21, 2024
@oscar-wallis oscar-wallis added the status: time-out Issuer creator has not responded within 2 weeks label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Connector: PyTorch 🔦 Relevant to optional packages, such as external connectors status: time-out Issuer creator has not responded within 2 weeks type: documentation 📖 Issues related to documentation type: question 🙋 Question about the code or its uses
Projects
None yet
Development

No branches or pull requests

3 participants