When I run the code, getting the error as:
AttributeError: 'list' object has no attribute 'values'
AttributeError Traceback (most recent call last)
<ipython-input-37-66115a52c5d6> in <module>
23 optimizer.zero_grad()
24
---> 25 output = model(X_tr)
26 optimizer.zero_grad()
27 loss = loss_func(output)
~\anaconda3\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
887 result = self._slow_forward(*input, **kwargs)
888 else:
--> 889 result = self.forward(*input, **kwargs)
890 for hook in itertools.chain(
891 _global_forward_hooks.values(),
<ipython-input-34-4a7275625fa6> in forward(self, x)
13
14 def forward(self,x):
---> 15 h = self.f(x)
16 return self.g(h)
17
~\anaconda3\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
887 result = self._slow_forward(*input, **kwargs)
888 else:
--> 889 result = self.forward(*input, **kwargs)
890 for hook in itertools.chain(
891 _global_forward_hooks.values(),
<ipython-input-32-ae2fe8e8ca2d> in forward(self, x)
34 x = self.fc(x[:, -1, :])
35 # out.size() --> 100, 10
---> 36 x = self.hybrid(x)
37 return T.cat((x, 1 - x), -1)
~\anaconda3\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
887 result = self._slow_forward(*input, **kwargs)
888 else:
--> 889 result = self.forward(*input, **kwargs)
890 for hook in itertools.chain(
891 _global_forward_hooks.values(),
<ipython-input-6-f66b87fe8d6c> in forward(self, input)
42
43 def forward(self, input):
---> 44 return HybridFunction.apply(input, self.quantum_circuit, self.shift)
<ipython-input-6-f66b87fe8d6c> in forward(ctx, input, quantum_circuit, shift)
8 ctx.quantum_circuit = quantum_circuit
9
---> 10 expectation_z = ctx.quantum_circuit.run(input[0].tolist())
11 result = torch.tensor([expectation_z])
12 ctx.save_for_backward(input, result)
<ipython-input-4-34122f68ae18> in run(self, thetas)
30 result = job.result().get_counts()
31
---> 32 counts = np.array(list(result.values()))
33 states = np.array(list(result.keys())).astype(float)
34
AttributeError: 'list' object has no attribute 'values'