You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import numpy as np
import paddle
import paddle_quantum as pq
from paddle_quantum.ansatz.circuit import Circuit
from paddle_quantum.visual import plot_state_in_bloch_sphere
File d:\Software\Anaconda3\anaconda3\envs\Qpaddle\lib\site-packages\paddle\nn\layer\layers.py:1254, in Layer.call(self, *inputs, **kwargs)
1245 if (
1246 (not in_declarative_mode())
1247 and (not self._forward_pre_hooks)
(...)
1251 and (not in_profiler_mode())
1252 ):
1253 self._build_once(*inputs, **kwargs)
-> 1254 return self.forward(*inputs, **kwargs)
1255 else:
1256 return self._dygraph_call_func(*inputs, **kwargs)
File d:\Software\Anaconda3\anaconda3\envs\Qpaddle\lib\site-packages\paddle_quantum\ansatz\circuit.py:1696, in Circuit.forward(self, state)
1694 state = state.clone()
1695 state.is_swap_back = False
-> 1696 state = super().forward(state)
...
1123 check_type(input, 'input', (list, tuple, Variable), 'concat')
ValueError: (InvalidArgument) The shape of input[0] and input[1] is expected to be equal.But received input[0]'s shape = [1], input[1]'s shape = [].
[Hint: Expected inputs_dims[i].size() == out_dims.size(), but received inputs_dims[i].size():0 != out_dims.size():1.] (at ..\paddle/phi/kernels/funcs/concat_funcs.h:55)
paddle-quantum == 2.4.0
将circ.rz(0)改为ry和rx都是正常运行
The text was updated successfully, but these errors were encountered:
import numpy as np
import paddle
import paddle_quantum as pq
from paddle_quantum.ansatz.circuit import Circuit
from paddle_quantum.visual import plot_state_in_bloch_sphere
num_qubit = 1 # 设定量子比特数
num_sample = 2000 # 设定采样次数
outputs_yz = list() # 储存采样电路输出
for _ in range(num_sample):
# 初始化量子神经网络
cir = Circuit(num_qubit)
cir.ry(0)
cir.rz(0)
# 输出态的密度矩阵
rho = cir(pq.state.zero_state(num_qubit))
outputs_yz.append(rho)
plot_state_in_bloch_sphere(outputs_yz, save_gif=True, filename='figures/bloch_yz.gif')
报错如下:
ValueError Traceback (most recent call last)
[e:](file:///E:/)代码\Variational Algorithm\work_1\VQLS\1-1Revision\Expressibility测试2.py in line 9
39 cir.rz(0)
40 # 输出态的密度矩阵
----> 41 rho = cir(pq.state.zero_state(num_qubit))
42 outputs_yz.append(rho)
44 # plot_state_in_bloch_sphere(outputs_yz, save_gif=True, filename='figures/bloch_yz.gif')
File d:\Software\Anaconda3\anaconda3\envs\Qpaddle\lib\site-packages\paddle\nn\layer\layers.py:1254, in Layer.call(self, *inputs, **kwargs)
1245 if (
1246 (not in_declarative_mode())
1247 and (not self._forward_pre_hooks)
(...)
1251 and (not in_profiler_mode())
1252 ):
1253 self._build_once(*inputs, **kwargs)
-> 1254 return self.forward(*inputs, **kwargs)
1255 else:
1256 return self._dygraph_call_func(*inputs, **kwargs)
File d:\Software\Anaconda3\anaconda3\envs\Qpaddle\lib\site-packages\paddle_quantum\ansatz\circuit.py:1696, in Circuit.forward(self, state)
1694 state = state.clone()
1695 state.is_swap_back = False
-> 1696 state = super().forward(state)
...
1123 check_type(input, 'input', (list, tuple, Variable), 'concat')
ValueError: (InvalidArgument) The shape of input[0] and input[1] is expected to be equal.But received input[0]'s shape = [1], input[1]'s shape = [].
[Hint: Expected inputs_dims[i].size() == out_dims.size(), but received inputs_dims[i].size():0 != out_dims.size():1.] (at ..\paddle/phi/kernels/funcs/concat_funcs.h:55)
paddle-quantum == 2.4.0
将circ.rz(0)改为ry和rx都是正常运行
The text was updated successfully, but these errors were encountered: