├── Autoencoder-MATLAB ├── ApplyLayer.m ├── ApplyNetwork.m ├── AutoData.m ├── AutoEncoder.m ├── AverageGeneralization.m ├── BrownianCircuit.m ├── Cluster.m ├── Comm.m ├── CostNetwork.m ├── Dat │ ├── dsf_test_ex1_train1_test1.mat │ ├── dsf_test_ex1_train1_test1_p1.mat │ ├── dsf_test_ex1_train1_test1_p10.mat │ ├── dsf_test_ex1_train1_test1_p11.mat │ ├── dsf_test_ex1_train1_test1_p2.mat │ ├── dsf_test_ex1_train1_test1_p3.mat │ ├── dsf_test_ex1_train1_test1_p4.mat │ ├── dsf_test_ex1_train1_test1_p5.mat │ ├── dsf_test_ex1_train1_test1_p6.mat │ ├── dsf_test_ex1_train1_test1_p7.mat │ ├── dsf_test_ex1_train1_test1_p8.mat │ ├── dsf_test_ex1_train1_test1_p9.mat │ ├── dsf_test_ex29_train1_test1.mat │ ├── dsf_train_ex1_train1.mat │ ├── dsf_train_ex1_train1_p1.mat │ ├── dsf_train_ex1_train1_p10.mat │ ├── dsf_train_ex1_train1_p11.mat │ ├── dsf_train_ex1_train1_p2.mat │ ├── dsf_train_ex1_train1_p3.mat │ ├── dsf_train_ex1_train1_p4.mat │ ├── dsf_train_ex1_train1_p5.mat │ ├── dsf_train_ex1_train1_p6.mat │ ├── dsf_train_ex1_train1_p7.mat │ ├── dsf_train_ex1_train1_p8.mat │ ├── dsf_train_ex1_train1_p9.mat │ ├── dsf_train_ex29_train1.mat │ ├── du_test_ex39_train2_test1.mat │ ├── du_test_ex39_train2_test1_p1.mat │ ├── du_test_ex39_train2_test1_p10.mat │ ├── du_test_ex39_train2_test1_p11.mat │ ├── du_test_ex39_train2_test1_p2.mat │ ├── du_test_ex39_train2_test1_p3.mat │ ├── du_test_ex39_train2_test1_p4.mat │ ├── du_test_ex39_train2_test1_p5.mat │ ├── du_test_ex39_train2_test1_p6.mat │ ├── du_test_ex39_train2_test1_p7.mat │ ├── du_test_ex39_train2_test1_p8.mat │ ├── du_test_ex39_train2_test1_p9.mat │ ├── du_train_ex39_train2.mat │ ├── du_train_ex39_train2_p1.mat │ ├── du_train_ex39_train2_p10.mat │ ├── du_train_ex39_train2_p11.mat │ ├── du_train_ex39_train2_p2.mat │ ├── du_train_ex39_train2_p3.mat │ ├── du_train_ex39_train2_p4.mat │ ├── du_train_ex39_train2_p5.mat │ ├── du_train_ex39_train2_p6.mat │ ├── du_train_ex39_train2_p7.mat │ ├── du_train_ex39_train2_p8.mat │ ├── du_train_ex39_train2_p9.mat │ ├── plot_dsf_test_ex1_train1_test1.mat │ ├── plot_dsf_test_ex29_train1_test1.mat │ ├── plot_dsf_train_ex1_train1.mat │ ├── plot_dsf_train_ex29_train1.mat │ └── plot_du_test_ex39_train2_test1.mat ├── DenoiseDephasing.m ├── DenoiseDephasing_Plot.m ├── DenoiseSpinFlips.m ├── DenoiseSpinFlips_Plot.m ├── DenoiseUnitary.m ├── DenoiseUnitary_Plot.m ├── Dephasing.m ├── DephasingGHZ.m ├── Dicke.m ├── FChannel.m ├── Fidelity.m ├── Fig │ ├── cost_dsf_train_ex1_train1.eps │ ├── cost_dsf_train_ex1_train1.fig │ ├── cost_dsf_train_ex1_train1.png │ ├── cost_dsf_train_ex29_train1.eps │ ├── cost_dsf_train_ex29_train1.fig │ ├── cost_dsf_train_ex29_train1.png │ ├── cost_du_train_ex39_train2.eps │ ├── cost_du_train_ex39_train2.fig │ ├── cost_du_train_ex39_train2.png │ ├── dn_dsf_test_ex29_train1_test1.eps │ ├── dn_dsf_test_ex29_train1_test1.fig │ ├── dn_dsf_test_ex29_train1_test1.png │ ├── dnvn_dsf_test_ex1_train1_test1.eps │ ├── dnvn_dsf_test_ex1_train1_test1.fig │ ├── dnvn_dsf_test_ex1_train1_test1.png │ ├── dnvn_du_test_ex39_train2_test1.eps │ ├── dnvn_du_test_ex39_train2_test1.fig │ └── dnvn_du_test_ex39_train2_test1.png ├── FlipAnalytics.m ├── FlipAnalyticsDicke.m ├── FlipAnalyticsGHZ.m ├── GHZ.m ├── GeneralizationTask.m ├── How to use this program.txt ├── Noisydata.m ├── Paperplot1.m ├── Paperplot2.m ├── Paperplot4.m ├── PlotCost.m ├── PlotDenoising.m ├── PlotDenoisingVsNoise.m ├── QuickInitilizer.m ├── RandomUnitary1.m ├── RandomUnitaryTrainingsData.m ├── Randomtrainingdata.m ├── Randomunitary.m ├── Resub_Paperplot1.m ├── Resub_Paperplot2.m ├── SpectralRange.m ├── SpinFlipNoise.m ├── TestRandomUnitary1.m ├── TrainNetwork.m └── UnitaryNoise.m ├── DQGAN ├── Cluster │ └── QGAN_50data10sv_100statData_100statData_1-1networkGen_1-1networkDis_lda1_ep0i01_rounds100_roundsGen1_roundsDis1_CvsLi_statMean │ │ └── 2021_12_14_qganComparison.py ├── ConnectedCluster │ └── QGAN_50data10sv_100statData_100statData_1-1networkGen_1-1networkDis_lda1_ep0i01_rounds300_roundsGen1_roundsDis1_conCvsLi_statMean │ │ └── 2021_11_30_qganComparison.py └── DQGAN.py ├── DQNN ├── Classification-Python │ ├── qnn_classification_bloch_1.ipynb │ └── qnn_classification_bloch_2.ipynb ├── DQNN.py ├── DeepQNN-MATLAB │ ├── ApplyLayer.m │ ├── ApplyNetwork.m │ ├── AutoData.m │ ├── AutoEncoder.m │ ├── AverageGeneralization.m │ ├── BrownianCircuit.m │ ├── Comm.m │ ├── CostNetwork.m │ ├── DenoiseSpinFlips.m │ ├── DenoiseSpinFlips_Plot.m │ ├── DenoiseUnitary.m │ ├── DenoiseUnitary_Plot.m │ ├── FChannel.m │ ├── Fidelity.m │ ├── FlipAnalyticsGHZ.m │ ├── GHZ.m │ ├── GeneralizationTask.m │ ├── How to use this program.txt │ ├── Noisydata.m │ ├── Paperplot1.m │ ├── Paperplot2.m │ ├── Paperplot4.m │ ├── PlotCost.m │ ├── PlotDenoising.m │ ├── PlotDenoisingVsNoise.m │ ├── QuickInitilizer.m │ ├── RandomUnitary1.m │ ├── RandomUnitaryTrainingsData.m │ ├── Randomtrainingdata.m │ ├── Randomunitary.m │ ├── SpectralRange.m │ ├── SpinFlipNoise.m │ ├── TestRandomUnitary1.m │ ├── TrainNetwork.m │ └── UnitaryNoise.m └── DeepQNN-Mathematica.nb ├── DQNN_basic.ipynb ├── DQNN_on_NISQ ├── execution.py ├── input │ ├── dqnn_2-2 │ │ ├── input_training_states.txt │ │ ├── input_validation_states.txt │ │ ├── params.txt │ │ └── unitary.txt │ └── qaoa_2qubits │ │ ├── input_training_states.txt │ │ ├── input_validation_states.txt │ │ ├── matrix_A.txt │ │ ├── matrix_B.txt │ │ ├── params.txt │ │ └── unitary.txt ├── main.py ├── network_classes.py ├── save_data.py ├── training.py ├── training_data.py └── user_config.py ├── GraphQNN ├── GraphQNN-Python.py ├── connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean │ ├── connectedClustersRandomShuffled_8pairs1sv_3-1network_adjT0i65and1_graph.png │ ├── connectedClustersRandomShuffled_8pairs1sv_3-1network_adjT0i65and1_graph.txt │ ├── connectedClustersRandomShuffled_8pairs1sv_3-1network_adjT0i65and1_matrix.txt │ ├── connectedClustersRandomShuffled_8pairs2sv_3-1network_adjT0i65and1_graph.png │ ├── connectedClustersRandomShuffled_8pairs2sv_3-1network_adjT0i65and1_graph.txt │ ├── connectedClustersRandomShuffled_8pairs2sv_3-1network_adjT0i65and1_matrix.txt │ ├── connectedClustersRandomShuffled_8pairs3sv_3-1network_adjT0i65and1_graph.png │ ├── connectedClustersRandomShuffled_8pairs3sv_3-1network_adjT0i65and1_graph.txt │ ├── connectedClustersRandomShuffled_8pairs3sv_3-1network_adjT0i65and1_matrix.txt │ ├── connectedClustersRandomShuffled_8pairs4sv_3-1network_adjT0i65and1_graph.png │ ├── connectedClustersRandomShuffled_8pairs4sv_3-1network_adjT0i65and1_graph.txt │ ├── connectedClustersRandomShuffled_8pairs4sv_3-1network_adjT0i65and1_matrix.txt │ ├── connectedClustersRandomShuffled_8pairs5sv_3-1network_adjT0i65and1_graph.png │ ├── connectedClustersRandomShuffled_8pairs5sv_3-1network_adjT0i65and1_graph.txt │ ├── connectedClustersRandomShuffled_8pairs5sv_3-1network_adjT0i65and1_matrix.txt │ ├── connectedClustersRandomShuffled_8pairs6sv_3-1network_adjT0i65and1_graph.png │ ├── connectedClustersRandomShuffled_8pairs6sv_3-1network_adjT0i65and1_graph.txt │ ├── connectedClustersRandomShuffled_8pairs6sv_3-1network_adjT0i65and1_matrix.txt │ ├── connectedClustersRandomShuffled_8pairs7sv_3-1network_adjT0i65and1_graph.png │ ├── connectedClustersRandomShuffled_8pairs7sv_3-1network_adjT0i65and1_graph.txt │ ├── connectedClustersRandomShuffled_8pairs7sv_3-1network_adjT0i65and1_matrix.txt │ ├── connectedClustersRandomShuffled_8pairs8sv_3-1network_adjT0i65and1_graph.png │ ├── connectedClustersRandomShuffled_8pairs8sv_3-1network_adjT0i65and1_graph.txt │ ├── connectedClustersRandomShuffled_8pairs8sv_3-1network_adjT0i65and1_matrix.txt │ ├── connectedClustersRandomShuffled_8pairs_1qubit_fidelities.png │ └── connectedClustersRandomShuffled_8pairs_1qubit_fidelities.txt └── lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean │ ├── __pycache__ │ └── code.cpython-37.pyc │ ├── code.py │ ├── lineOutputRandomShuffled_10pairs10sv_3-1network_adjT0i93and1_graph.png │ ├── lineOutputRandomShuffled_10pairs10sv_3-1network_adjT0i93and1_graph.txt │ ├── lineOutputRandomShuffled_10pairs10sv_3-1network_adjT0i93and1_matrix.txt │ ├── lineOutputRandomShuffled_10pairs1sv_3-1network_adjT0i93and1_graph.png │ ├── lineOutputRandomShuffled_10pairs1sv_3-1network_adjT0i93and1_graph.txt │ ├── lineOutputRandomShuffled_10pairs1sv_3-1network_adjT0i93and1_matrix.txt │ ├── lineOutputRandomShuffled_10pairs2sv_3-1network_adjT0i93and1_graph.png │ ├── lineOutputRandomShuffled_10pairs2sv_3-1network_adjT0i93and1_graph.txt │ ├── lineOutputRandomShuffled_10pairs2sv_3-1network_adjT0i93and1_matrix.txt │ ├── lineOutputRandomShuffled_10pairs3sv_3-1network_adjT0i93and1_graph.png │ ├── lineOutputRandomShuffled_10pairs3sv_3-1network_adjT0i93and1_graph.txt │ ├── lineOutputRandomShuffled_10pairs3sv_3-1network_adjT0i93and1_matrix.txt │ ├── lineOutputRandomShuffled_10pairs4sv_3-1network_adjT0i93and1_graph.png │ ├── lineOutputRandomShuffled_10pairs4sv_3-1network_adjT0i93and1_graph.txt │ ├── lineOutputRandomShuffled_10pairs4sv_3-1network_adjT0i93and1_matrix.txt │ ├── lineOutputRandomShuffled_10pairs5sv_3-1network_adjT0i93and1_graph.png │ ├── lineOutputRandomShuffled_10pairs5sv_3-1network_adjT0i93and1_graph.txt │ ├── lineOutputRandomShuffled_10pairs5sv_3-1network_adjT0i93and1_matrix.txt │ ├── lineOutputRandomShuffled_10pairs6sv_3-1network_adjT0i93and1_graph.png │ ├── lineOutputRandomShuffled_10pairs6sv_3-1network_adjT0i93and1_graph.txt │ ├── lineOutputRandomShuffled_10pairs6sv_3-1network_adjT0i93and1_matrix.txt │ ├── lineOutputRandomShuffled_10pairs7sv_3-1network_adjT0i93and1_graph.png │ ├── lineOutputRandomShuffled_10pairs7sv_3-1network_adjT0i93and1_graph.txt │ ├── lineOutputRandomShuffled_10pairs7sv_3-1network_adjT0i93and1_matrix.txt │ ├── lineOutputRandomShuffled_10pairs8sv_3-1network_adjT0i93and1_graph.png │ ├── lineOutputRandomShuffled_10pairs8sv_3-1network_adjT0i93and1_graph.txt │ ├── lineOutputRandomShuffled_10pairs8sv_3-1network_adjT0i93and1_matrix.txt │ ├── lineOutputRandomShuffled_10pairs9sv_3-1network_adjT0i93and1_graph.png │ ├── lineOutputRandomShuffled_10pairs9sv_3-1network_adjT0i93and1_graph.txt │ ├── lineOutputRandomShuffled_10pairs9sv_3-1network_adjT0i93and1_matrix.txt │ ├── lineOutputRandomShuffled_10pairs_1qubit_fidelities.png │ └── lineOutputRandomShuffled_10pairs_1qubit_fidelities.txt ├── LICENSE ├── QRNN └── QRNN.ipynb └── README.md /Autoencoder-MATLAB/ApplyLayer.m: -------------------------------------------------------------------------------- 1 | %Application of all unitaries in one given layer. This corresponds to the 2 | %action of the \mathcal{E} on a given start density matrix rho_in. 3 | function rho_out = ApplyLayer(rho_in,U,N_CorrLay,N_PrevLay) 4 | 5 | %pho_in (pho_out): input (output) state of the corresponding layer 6 | %N_CorrLay (N_PrevLay): Number of neurons in the corresponding (previous) Layer 7 | %U array containing all N_CorrLay Unitaries of the corresponding Layer 8 | 9 | 10 | %Initialising Input State on all N_CorrLay + N_PrevLay Qubits 11 | RHO_in_whole = kron(rho_in,[1;zeros(2^N_CorrLay -1,1)]*[1;zeros(2^N_CorrLay -1,1)]'); 12 | 13 | %Calculating Output on all N_CorrLay + N_PrevLay Qubits 14 | RHO_out_whole = RHO_in_whole; 15 | for j= 1:N_CorrLay 16 | V = Swap(kron(U(:,:,j),eye(2^(N_CorrLay - 1))),[N_PrevLay+1,N_PrevLay+j],2*ones(1,N_CorrLay+N_PrevLay)); 17 | RHO_out_whole = V*RHO_out_whole*V'; 18 | end 19 | 20 | %Calculating Output state of the Neurons in the corresponding Layer 21 | rho_out = PartialTrace(RHO_out_whole,1:N_PrevLay,2*ones(1,N_CorrLay+N_PrevLay)); 22 | 23 | 24 | 25 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/ApplyNetwork.m: -------------------------------------------------------------------------------- 1 | %Calculates the output state/density matrix for som given input vector 2 | %phi_in 3 | function rho_out = ApplyNetwork(phi_in,U,M) 4 | 5 | % M array of Number of Neurons in each layer, i.e. size(M,2) = Num_Layers, M(1,j) = Num_Neurons in Layer j 6 | 7 | 8 | N_Layers = size(M,2); 9 | 10 | rho_out = phi_in*phi_in'; 11 | 12 | for k = 2:N_Layers 13 | rho_out = ApplyLayer(rho_out,U{k},M(k),M(k-1)); 14 | end 15 | 16 | 17 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/AutoData.m: -------------------------------------------------------------------------------- 1 | 2 | function [phi_in, phi_out, test_in, test_out] = AutoData(mode, n, m) 3 | dim = 2^m; 4 | if mode == 1 5 | p = 0.4; 6 | n0 = round(p*n); 7 | phi0 = ghz(m, 0); 8 | flip0 = [0, 1; 1, 0]; 9 | id = eye(2); 10 | flip = zeros(dim,dim,n); 11 | phi = zeros(dim,n); 12 | for i = 1:m 13 | f = flip0; 14 | for j = 1:(i-1) 15 | f = kron(id, f); 16 | end 17 | for j = (i+1):m 18 | f = kron(f, id); 19 | end 20 | flip(:,:,i) = f; 21 | phi(:,i) = f*phi0; 22 | end 23 | % phi_rand = phi(:,randi(m,1,3*n)); 24 | % phi_in = phi_rand(:,1:n); 25 | % phi_out = phi_rand(:,n+1:2*n); 26 | % test_in = phi_rand(:,2*n+1:end); 27 | phi_rand = phi(:,randi(m,1,3*n0)); 28 | rep_phi0 = repmat(phi0, 1, n-n0); 29 | phi_in = cat(2, phi_rand(:,1:n0), rep_phi0); 30 | phi_in = phi_in(:,randi(n,1,n)); 31 | phi_out = cat(2, phi_rand(:,n0+1:2*n0), rep_phi0); 32 | phi_out = phi_out(:,randi(n,1,n)); 33 | test_in = cat(2, phi_rand(:,2*n0+1:end), rep_phi0); 34 | test_out = repmat(phi0, 1, n); 35 | end 36 | if mode == 2 37 | ghz_plus = ghz(m,0); 38 | ghz_minus = ghz(m,pi); 39 | phi_plus = repmat(ghz_plus, 1, floor(n/2)); 40 | phi_minus = repmat(ghz_minus, 1, ceil(n/2)); 41 | phi_in = cat(2, phi_plus, phi_minus); 42 | phi_out = phi_in; 43 | test_in = cat(2, ghz_plus, ghz_minus); 44 | test_out = test_in; 45 | end 46 | if mode == 3 47 | sgm = 0.5; 48 | phi_rand = repmat(exp(1i*normrnd(0, sgm, [1,3*n])),dim,1).*ghz(m,normrnd(0, sgm, [1,3*n])); 49 | phi_in = phi_rand(:,1:n); 50 | phi_out = phi_rand(:,n+1:2*n); 51 | test_in = phi_rand(:,2*n+1:end); 52 | test_out = repmat(ghz(m,0), 1, n); 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /Autoencoder-MATLAB/AutoEncoder.m: -------------------------------------------------------------------------------- 1 | 2 | m = 3; 3 | M = [m,1,m]; 4 | n = 50; 5 | iter = 70; 6 | mode = 3; 7 | lambda = 0.8; %0.5 8 | dim = 2^m; 9 | if mode == 1 10 | path = 'Flip'; 11 | elseif mode == 3 12 | path = 'Rot'; 13 | end 14 | 15 | U = QuickInitilizer(M); 16 | tic 17 | [in, out, tin, tout] = AutoData(mode, n, m); 18 | [U, CList] = TrainNetwork(in, out, U, M, lambda, iter); 19 | toc 20 | 21 | C = CostNetwork(tin, tout, U, M); 22 | disp(C) 23 | 24 | plot(CList) 25 | 26 | datafid = fidelity1(tin, tout); 27 | netout = zeros(dim, dim, n); 28 | for i = 1:n 29 | netout(:,:,i) = ApplyNetwork(tin(:,i), U, M); 30 | end 31 | netfid = fidelity2(netout, tout); 32 | 33 | figure 34 | hold 35 | plot(1:n, datafid, 'rd', 'LineWidth', 2) 36 | plot(1:n, netfid, 'b+', 'LineWidth', 2) 37 | xlabel('Sample') 38 | ylabel('GHZ Fidelity') 39 | saveas(gcf, strcat(path, '_Fid.png')) 40 | 41 | figure 42 | plot(1:iter, CList, 'LineWidth', 2) 43 | xlabel('Iteration') 44 | ylabel('Cost') 45 | saveas(gcf, strcat(path, '_Cost.png')) 46 | 47 | function flist = fidelity1(in, out) % vectors 48 | flist = abs(dot(out, in, 1)).^2; 49 | end 50 | 51 | function flist = fidelity2(in, out) % in: density matrices, out: vectors 52 | n = length(out); 53 | flist = zeros(n,1); 54 | for i = 1:n 55 | flist(i) = real(dot(out(:,i), in(:,:,i)*out(:,i))); 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /Autoencoder-MATLAB/AverageGeneralization.m: -------------------------------------------------------------------------------- 1 | %This function averages over 20 rounds of the Generalization task 2 | function [z_3,z_ave] = AverageGeneralization 3 | z_3 = zeros(20,8); 4 | z_ave = zeros(1,8); 5 | 6 | %Specify the right M here 7 | M =[3,3]; 8 | 9 | for j =1:20 10 | 11 | %Specify how the traingsdata should be chosen here 12 | [phi_in,phi_out] = RandomUnitaryTrainingsData(10,8); 13 | 14 | U = QuickInitilizer(M); 15 | 16 | z_3(j,:) = GeneralizationTask(phi_in,phi_out,U,M); 17 | z_ave = z_ave + z_3(j,:); 18 | end 19 | z_ave = z_ave/20; 20 | 21 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/BrownianCircuit.m: -------------------------------------------------------------------------------- 1 | function U = BrownianCircuit(dim,n,dt) 2 | %BrownianCircuit(dim,n,var,dt) creates a random unitary matrix by multiplying 3 | % exp(i H_1 dt) exp(i H_2 dt) ... exp(i H_n dt) 4 | %for random normal distributed hermitian dim-dimensional matricies \{ H_i \}_{i=1}^{n} standard deviation 1/2. 5 | 6 | U = eye(dim); 7 | 8 | for j= 1:n 9 | Re = randn(dim); 10 | Im = 1i*randn(dim); 11 | C = Re + Im; 12 | H = (C + C')/4; 13 | U = U*expm(1i*H*dt); 14 | end 15 | end 16 | 17 | -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Cluster.m: -------------------------------------------------------------------------------- 1 | function psi = Cluster(Gamma) 2 | % Cluster creates cluster states 3 | % 4 | % in: 5 | % Gamma: adjacency matrix, 6 | % neighbors: 1; else, including diagonal: 0 7 | % out: 8 | % psi: m-qubit cluster state with adjacency matrix Gamma \in {0,1}^(m x m), 9 | % sum_{a \in {0,1}^m} (-1)^(a^T*Gamma*a/2) |a>, 10 | % 0 in a corresponds to [1,0], 1 to [0,1], 11 | % joint eigenstates of K_j with eigenvalue 1, 12 | % K_j: sigma_x on jth qubit, sigma_z on neighbors, 13 | % in the tensor product basis 14 | 15 | m = length(Gamma); % number of qubits 16 | d = 2^m; 17 | ind = 1:d; 18 | 19 | % binary basis (rows) 20 | % 0 ~ [1,0], 1 ~ [0,1] 21 | % ordered according to tensor product basis 22 | binaries1 = dec2bin(ind-1, m); 23 | binaries2 = reshape(str2num(binaries1(:)), d, m); 24 | 25 | sign = diag(binaries2 * Gamma * binaries2') / 2; 26 | psi = (-1).^sign; 27 | psi = psi / sqrt(d); 28 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Comm.m: -------------------------------------------------------------------------------- 1 | %Calculates Commutator of matrix A and B 2 | function C = Comm(A,B) 3 | 4 | C = A*B -B*A; 5 | 6 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/CostNetwork.m: -------------------------------------------------------------------------------- 1 | %Calculates Cost function of Network given a set of input and target output 2 | %states 3 | function C = CostNetwork(phi_in,phi_out,U,M) 4 | 5 | %phi_in (phi_out): array with columns being the input (output) vectors 6 | N_NumTrain = size(phi_in,2); 7 | C = 0; 8 | 9 | for x=1:N_NumTrain 10 | C = C + dot(phi_out(:,x),ApplyNetwork(phi_in(:,x),U,M)*phi_out(:,x)); 11 | end 12 | 13 | C = real(C/N_NumTrain); 14 | 15 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p1.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p10.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p10.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p11.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p11.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p2.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p3.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p3.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p4.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p4.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p5.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p5.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p6.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p6.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p7.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p7.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p8.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p8.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p9.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_test_ex1_train1_test1_p9.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_test_ex29_train1_test1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_test_ex29_train1_test1.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_train_ex1_train1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_train_ex1_train1.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p1.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p10.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p10.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p11.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p11.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p2.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p3.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p3.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p4.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p4.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p5.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p5.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p6.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p6.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p7.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p7.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p8.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p8.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p9.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_train_ex1_train1_p9.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/dsf_train_ex29_train1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/dsf_train_ex29_train1.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p1.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p10.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p10.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p11.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p11.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p2.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p3.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p3.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p4.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p4.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p5.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p5.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p6.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p6.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p7.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p7.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p8.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p8.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p9.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_test_ex39_train2_test1_p9.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_train_ex39_train2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_train_ex39_train2.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_train_ex39_train2_p1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_train_ex39_train2_p1.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_train_ex39_train2_p10.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_train_ex39_train2_p10.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_train_ex39_train2_p11.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_train_ex39_train2_p11.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_train_ex39_train2_p2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_train_ex39_train2_p2.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_train_ex39_train2_p3.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_train_ex39_train2_p3.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_train_ex39_train2_p4.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_train_ex39_train2_p4.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_train_ex39_train2_p5.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_train_ex39_train2_p5.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_train_ex39_train2_p6.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_train_ex39_train2_p6.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_train_ex39_train2_p7.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_train_ex39_train2_p7.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_train_ex39_train2_p8.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_train_ex39_train2_p8.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/du_train_ex39_train2_p9.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/du_train_ex39_train2_p9.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/plot_dsf_test_ex1_train1_test1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/plot_dsf_test_ex1_train1_test1.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/plot_dsf_test_ex29_train1_test1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/plot_dsf_test_ex29_train1_test1.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/plot_dsf_train_ex1_train1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/plot_dsf_train_ex1_train1.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/plot_dsf_train_ex29_train1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/plot_dsf_train_ex29_train1.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dat/plot_du_test_ex39_train2_test1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Dat/plot_du_test_ex39_train2_test1.mat -------------------------------------------------------------------------------- /Autoencoder-MATLAB/DenoiseDephasing_Plot.m: -------------------------------------------------------------------------------- 1 | 2 | mode = 'test'; % 'train' or 'test' 3 | example = 39; 4 | id_train = 4; 5 | id_test = 1; 6 | 7 | % examples 8 | 9 | % GHZ states 10 | % 1: [3,1,3] 11 | % 2: [3,3,3] 12 | % 3: [3,1,3,1,3] training [3,1,3] 13 | % 4: [3,1,3,1,3] 14 | % 5: [4,1,4] 15 | % 6: [4,2,4] 16 | % 7: [4,2,4] sparse 17 | % 8: [4,2,1,2,4] 18 | % 9: [4,2,1,2,4] sparse 19 | % 10: [4,1,4,1,4] training [4,1,4] 20 | % 11: [4,1,4,1,4] 21 | % 12: [5,1,5] 22 | % 13: [5,3,5] 23 | % 14: [5,3,5] sparse 24 | % 15: [5,3,1,3,5] 25 | % 16: [5,3,1,3,5] sparse 26 | % 17: [5,1,5,1,5] training [5,1,5] 27 | % 18: [5,1,5,1,5] 28 | % 19: [3,1,3] denoising GHZ + and - 29 | % 20: [3,1,3] denoising GHZ with random phase 30 | 31 | % W-states Dicke(3,1) 32 | % 30: [3,1,3] 33 | % 31: [3,1,3,1,3] training [3,1,3] 34 | 35 | % Dicke states Dicke(4,2) 36 | % 32: [4,1,4] 37 | % 33: [4,1,4,1,4] training [4,1,4] 38 | % 34: [4,2,1,2,4] 39 | % 35: [4,2,1,2,4] sparse 40 | 41 | switch mode 42 | case 'train' 43 | switch example 44 | case {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,... 45 | 30, 31, 32, 33, 34, 35} 46 | savename = strcat('dp_train_ex', num2str(example), '_train', num2str(id_train)); 47 | 48 | % load from example_train (title) 49 | load(strcat('Dat/', savename, '.mat'), 'pnum') 50 | % title = strcat('n=', num2str(n1), ', l=', num2str(lambda)); 51 | 52 | % load from example_train_p, legend 53 | cost = cell(1,pnum); 54 | legend = cell(1,pnum); 55 | for i = 1:pnum 56 | load(strcat('Dat/', savename, '_p', num2str(i), '.mat'), 'p', 'CList') 57 | cost{i} = CList; 58 | legend{i} = strcat('p=', num2str(p)); 59 | end 60 | 61 | % plot 62 | % PlotCost(cost, 'savename', savename, 'legend', legend, 'title', title) 63 | PlotCost(cost, 'savename', savename, 'legend', legend) 64 | 65 | % save 66 | % save(strcat('Dat/plot_', savename), 'cost', 'legend', 'title') 67 | save(strcat('Dat/plot_', savename), 'cost', 'legend') 68 | otherwise 69 | error('Choose an example from 1 to 20 or 30 to 35.') 70 | end 71 | 72 | case 'test' 73 | switch example 74 | case {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,... 75 | 30, 31, 32, 33, 34, 35} 76 | 77 | savename = strcat('dp_test_ex', num2str(example), '_train',... 78 | num2str(id_train), '_test', num2str(id_test)); 79 | 80 | % load from example_train_test 81 | load(strcat('Dat/', savename, '.mat'), 'n2', 'pnum') 82 | 83 | % load from example_train_test_p 84 | noise = zeros(1,pnum); 85 | mfid_in = zeros(1,pnum); 86 | sdv_in = zeros(1,pnum); 87 | mfid_out = zeros(1,pnum); 88 | sdv_out = zeros(1,pnum); 89 | for i = 1:pnum 90 | load(strcat('Dat/', savename, '_p', num2str(i), '.mat'),... 91 | 'p', 'meanfid_in','varfid_in', 'meanfid_out', 'varfid_out') 92 | noise(i) = p; 93 | mfid_in(i) = meanfid_in; 94 | sdv_in(i) = sqrt(varfid_in); 95 | mfid_out(i) = meanfid_out; 96 | sdv_out(i) = sqrt(varfid_out); 97 | end 98 | 99 | fid = {mfid_in, mfid_out}; 100 | sdv = {sdv_in, sdv_out}; 101 | legend = ["noisy", "denoised"]; 102 | 103 | % plot 104 | PlotDenoisingVsNoise(noise, fid,... 105 | 'sdv_fidelity', sdv, 'savename', savename, 'legend', legend, 'lposition', [0.25,0.235],... 106 | 'xlabel', 'phase spread $\sigma/\pi$', 'ylabel', 'fidelity with GHZ-0',... 107 | 'plotstyle', {{".", 'MarkerSize', 25, 'LineWidth', 1.5, 'Color', [0.85,0.325,0.098]},... 108 | {"o", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 20, 'Color', [0.929,0.694,0.125]}}) 109 | 110 | % save 111 | save(strcat('Dat/plot_', savename), 'noise', 'fid', 'sdv', 'legend') 112 | 113 | otherwise 114 | error('Choose an example from 1 to 20 or 30 to 35.') 115 | end 116 | otherwise 117 | error('Valid modes are "train" and "test".') 118 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/DenoiseUnitary_Plot.m: -------------------------------------------------------------------------------- 1 | 2 | mode = 'test'; % 'train' or 'test' 3 | example = 34; 4 | id_train = 1; 5 | id_test = 1; 6 | 7 | % examples 8 | 9 | % GHZ states 10 | % 1: [3,1,3] 11 | % 2: [3,3,3] 12 | % 3: [3,1,3,1,3] training [3,1,3] 13 | % 4: [3,1,3,1,3] 14 | % 5: [4,1,4] 15 | % 6: [4,2,4] 16 | % 7: [4,2,4] sparse 17 | % 8: [4,2,1,2,4] 18 | % 9: [4,2,1,2,4] sparse 19 | % 10: [4,1,4,1,4] training [4,1,4] 20 | % 11: [4,1,4,1,4] 21 | % 12: [5,1,5] 22 | % 13: [5,3,5] 23 | % 14: [5,3,5] sparse 24 | % 15: [5,3,1,3,5] 25 | % 16: [5,3,1,3,5] sparse 26 | % 17: [5,1,5,1,5] training [5,1,5] 27 | % 18: [5,1,5,1,5] 28 | % 19: [3,1,3] denoising GHZ + and - 29 | % 20: [3,1,3] denoising GHZ with random phase 30 | 31 | % W-states Dicke(3,1) 32 | % 30: [3,1,3] 33 | % 31: [3,1,3,1,3] training [3,1,3] 34 | 35 | % Dicke states Dicke(4,2) 36 | % 32: [4,1,4] 37 | % 33: [4,1,4,1,4] training [4,1,4] 38 | % 34: [4,2,1,2,4] 39 | % 35: [4,2,1,2,4] sparse 40 | 41 | % Cluster state with Gamma = [0,1,0,1; 1,0,1,0; 0,1,0,1; 1,0,1,0] 42 | % 37: [4,1,4] 43 | % 38: [4,1,4,1,4] training [4,1,4] 44 | % 39: [4,2,1,2,4] 45 | % 40: [4,2,1,2,4] sparse 46 | 47 | switch mode 48 | case 'train' 49 | switch example 50 | case {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,... 51 | 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40} 52 | savename = strcat('du_train_ex', num2str(example), '_train', num2str(id_train)); 53 | 54 | % load from example_train (title) 55 | load(strcat('Dat/', savename, '.mat'), 'pnum') 56 | % title = strcat('n=', num2str(n1), ', l=', num2str(lambda)); 57 | 58 | % load from example_train_p, legend 59 | cost = cell(1,pnum); 60 | legend = cell(1,pnum); 61 | for i = 1:pnum 62 | load(strcat('Dat/', savename, '_p', num2str(i), '.mat'), 'p', 'CList') 63 | cost{i} = CList; 64 | legend{i} = strcat('p=', num2str(p)); 65 | end 66 | 67 | % plot 68 | % PlotCost(cost, 'savename', savename, 'legend', legend, 'title', title) 69 | PlotCost(cost, 'savename', savename, 'legend', legend) 70 | 71 | % save 72 | % save(strcat('Dat/plot_', savename), 'cost', 'legend', 'title') 73 | save(strcat('Dat/plot_', savename), 'cost', 'legend') 74 | otherwise 75 | error('Choose an example from 1 to 20 or 30 to 40.') 76 | end 77 | 78 | case 'test' 79 | switch example 80 | case {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,... 81 | 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40} 82 | 83 | savename = strcat('du_test_ex', num2str(example), '_train',... 84 | num2str(id_train), '_test', num2str(id_test)); 85 | 86 | % load from example_train_test 87 | load(strcat('Dat/', savename, '.mat'), 'n2', 'pnum', 'M') 88 | 89 | % load from example_train_test_p 90 | noise = zeros(1,pnum); 91 | mfid_in = zeros(1,pnum); 92 | sdv_in = zeros(1,pnum); 93 | mfid_out = zeros(1,pnum); 94 | sdv_out = zeros(1,pnum); 95 | for i = 1:pnum 96 | load(strcat('Dat/', savename, '_p', num2str(i), '.mat'),... 97 | 'p', 'meanfid_in','varfid_in', 'meanfid_out', 'varfid_out') 98 | noise(i) = p; 99 | mfid_in(i) = meanfid_in; 100 | sdv_in(i) = sqrt(varfid_in); 101 | mfid_out(i) = meanfid_out; 102 | sdv_out(i) = sqrt(varfid_out); 103 | end 104 | 105 | fid = {mfid_in, mfid_out}; 106 | sdv = {sdv_in, sdv_out}; 107 | legend = ["noisy", "[" + regexprep(num2str(M), '\s+', ',')+ "] denoised"]; 108 | 109 | if 1 <= example && example <= 18 110 | state = 'GHZ-0'; 111 | elseif example == 19 112 | state = 'GHZ-0/GHZ-$\pi$'; 113 | elseif example == 20 114 | state = 'GHZ-$\phi$'; 115 | elseif 30 <= example && example <= 31 116 | state = 'W'; 117 | elseif 32 <= example && example <= 36 118 | state = '$|2,2\rangle$'; 119 | elseif 37 <= example && example <= 40 120 | state = 'G$_{sq}$'; 121 | end 122 | 123 | % plot 124 | PlotDenoisingVsNoise(noise, fid,... 125 | 'sdv_fidelity', sdv, 'savename', savename, 'legend', legend, 'lposition', [0.307,0.162],... 126 | 'xlabel', 'noise strength q', 'ylabel', "fidelity with " + state,... 127 | 'plotstyle', {{".", 'MarkerSize', 25, 'LineWidth', 1.5, 'Color', [0.85,0.325,0.098]},... 128 | {"o", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 20, 'Color', [0.929,0.694,0.125]}}) 129 | 130 | % save 131 | save(strcat('Dat/plot_', savename), 'noise', 'fid', 'sdv', 'legend') 132 | 133 | otherwise 134 | error('Choose an example from 1 to 20 or 30 to 40.') 135 | end 136 | otherwise 137 | error('Valid modes are "train" and "test".') 138 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dephasing.m: -------------------------------------------------------------------------------- 1 | function [psi_noisy, varargout] = Dephasing(psi, n, p) 2 | % Dephasing applies n times dephasing noise to an m-qubit state psi 3 | % with dephasing probability p per qubit 4 | % 5 | % in: 6 | % psi: noiseless m-qubit state in tensor product basis as column vector 7 | % n: number of noise realizations 8 | % p: dephasing probability per qubit, maximal physical value is 0.5 9 | % out: 10 | % psi_noisy: psi_noisy(:,i) is the ith realization of a noisy psi 11 | % varargout: 12 | % {1}: n-element logical array v 13 | % with v(i)= 1 if psi_noisy(:,i) experienced only 0 or 1 phase flips. 14 | 15 | if p > 0.5 16 | error('Dephasing probability per qubit greater than 0.5 is unphysical.') 17 | end 18 | 19 | dim = length(psi); % dimension of Hilbert space 20 | m = log2(dim); % number of qubits 21 | 22 | % define flips(:,:,i) as phase flip of ith spin 23 | flip1 = [1, 0; 0, -1]; % dephasing for one qubit 24 | id = eye(2); 25 | flips = zeros(dim, dim, m); 26 | for i = 1:m 27 | f = flip1; 28 | for j = 1:(i-1) 29 | f = kron(id, f); 30 | end 31 | for j = (i+1):m 32 | f = kron(f, id); 33 | end 34 | flips(:,:,i) = f; 35 | end 36 | 37 | % for every noise realization psi_noisy(:,i) and every qubit j 38 | % draw random number r(j) from uniform distribution in (0, 1) 39 | % and apply jth dephasing with probability p, i.e. if r(j) <= p 40 | psi_noisy = zeros(dim, n); 41 | varargout = zeros(n,1); 42 | for i = 1:n 43 | r = rand(m,1); % random numbers 44 | pn = psi; 45 | for j = 1:m 46 | if r(j) <= p 47 | pn = flips(:,:,j) * pn; % apply phase flip 48 | end 49 | end 50 | psi_noisy(:,i) = pn; 51 | nflips = (r <= p); 52 | if sum(nflips) <= 1 % maximally one phase flip 53 | varargout(i) = 1; 54 | end 55 | end 56 | varargout = {logical(varargout)}; 57 | end 58 | -------------------------------------------------------------------------------- /Autoencoder-MATLAB/DephasingGHZ.m: -------------------------------------------------------------------------------- 1 | function GHZ_noisy = DephasingGHZ(m, n, p, mean_phi) 2 | % Dephasing applies n times dephasing noise to an m-qubit GHZ state 3 | % with variance 2*pi*p. 4 | % 5 | % in: 6 | % m: number of qubits 7 | % phi (optional, default = 0): array of relative phases 8 | % n: number of noise realizations 9 | % p: dephasing probability per qubit, maximal physical value is 0.5 10 | % out: 11 | % GHZ_noisy: GHZ_noisy(:,i) is the ith realization of a noisy psi 12 | 13 | if nargin < 4 14 | mean_phi = 0; 15 | end 16 | phases = mean_phi + randn(n,1)*pi*p;%/sqrt(m); 17 | 18 | GHZ_noisy = GHZ(m,phases); 19 | 20 | end 21 | -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Dicke.m: -------------------------------------------------------------------------------- 1 | function psi = Dicke(m, k) 2 | % Dicke creates Dicke states 3 | % 4 | % in: 5 | % m: number of qubits 6 | % k: number of up spins 7 | % out: 8 | % psi: m-qubit Dicke state with k up spins, 9 | % i.e. the symmetrization of |1>^k |0>^(m-k), 10 | % in the tensor product basis 11 | % Dicke(3, 1) is the W-state 12 | % Dicke(m, 1) is the generalized W-state 13 | 14 | n = nchoosek(m,k); 15 | binaries = zeros([n, m]); 16 | % rows: binary vectors for all distinct permutations 17 | 18 | perms = nchoosek(1:m, k); % column indeces of the ones for each permutation 19 | rows = kron(ones(1, k), 1:n); 20 | cols = perms(:)'; 21 | 22 | binaries(sub2ind([n, m], rows, cols)) = 1; 23 | 24 | binaries2 = 1 - fliplr(binaries); 25 | % MATLAB binary numbers: [1, 0] = 1, [0, 1] = 2 etc. 26 | % the flip is optional when summing over permutations 27 | % bitwise inversion b --> 1-b because canonically: 28 | % |1> ~ (1, 0) ~ small index in tensor product state, 29 | % |0> ~ (0, 1) ~ large index in tensor product state 30 | 31 | % each permutation contributes one 1 to psi 32 | ind = bi2de(binaries2) + 1; % indeces of the ones 33 | 34 | psi = zeros(2^m, 1); 35 | psi(ind) = 1; 36 | psi = psi / sqrt(sum(psi)); 37 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/FChannel.m: -------------------------------------------------------------------------------- 1 | %Applicaton of F (conjugate) Channel 2 | function rho_result = FChannel(rho_start,U,N_StartLay,N_ResLay) 3 | 4 | %This function maps the start density matrix rho_start to the image under the F 5 | %channel, which is rho_result. 6 | 7 | %N_StartLay: Number of neurons in the starting layer where rho_start lives. 8 | %N_ResLay: Number of neurons in the resulting layer where rho_result lives. 9 | 10 | RHO_whole = kron(eye(2^N_ResLay),rho_start); 11 | 12 | for j = 1 : N_StartLay 13 | j_1 = N_StartLay - j +1; 14 | V = Swap(kron(U(:,:,j_1),eye(2^(N_StartLay - 1))),[N_ResLay+1,N_ResLay+j_1],2*ones(1,N_StartLay+N_ResLay)); 15 | RHO_whole = V'*RHO_whole*V; 16 | end 17 | RHO_whole = kron(eye(2^N_ResLay),[1;zeros(2^N_StartLay-1,1)]*[1;zeros(2^N_StartLay-1,1)]')*RHO_whole; 18 | rho_result = PartialTrace(RHO_whole,N_ResLay+1:N_ResLay+N_StartLay,2*ones(1,N_StartLay+N_ResLay)); 19 | end 20 | -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Fidelity.m: -------------------------------------------------------------------------------- 1 | function flist = Fidelity(target, compare) 2 | % Fidelity computes the fidelity between pure target and 3 | % pure or mixed comparison states 4 | % 5 | % in: 6 | % target: target(:,i) is the ith pure target state of length > 1 7 | % compare: compare(:,i) is the ith pure state or 8 | % compare(:,:,i) is the ith density matrix 9 | % to be compared to the ith target state 10 | % out: 11 | % flist: array of fidelities 12 | 13 | st = size(target); 14 | sc = size(compare); 15 | n = st(end); % number of fidelities 16 | typec = length(sc); % determine if compare is mixed or pure 17 | if sc(end) ~= n 18 | if n == 1 && isequal(sc, [st(1), st(1)]) 19 | % ensure that a single density matrix is not interpreted as two vectors 20 | typec = 3; 21 | else 22 | error('The last dimensions of the input arguments have to match.') 23 | end 24 | end 25 | if typec == 2 % pure-pure state fidelity 26 | flist = abs(dot(compare, target)).^2; 27 | elseif typec == 3 % pure-mixed state fidelity 28 | flist = zeros(1,n); 29 | for i = 1:n 30 | flist(i) = real(dot(target(:,i), compare(:,:,i)*target(:,i))); 31 | end 32 | else 33 | error('Second input argument has wrong number of dimensions.') 34 | end 35 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Fig/cost_dsf_train_ex1_train1.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Fig/cost_dsf_train_ex1_train1.fig -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Fig/cost_dsf_train_ex1_train1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Fig/cost_dsf_train_ex1_train1.png -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Fig/cost_dsf_train_ex29_train1.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Fig/cost_dsf_train_ex29_train1.fig -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Fig/cost_dsf_train_ex29_train1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Fig/cost_dsf_train_ex29_train1.png -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Fig/cost_du_train_ex39_train2.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Fig/cost_du_train_ex39_train2.fig -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Fig/cost_du_train_ex39_train2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Fig/cost_du_train_ex39_train2.png -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Fig/dn_dsf_test_ex29_train1_test1.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Fig/dn_dsf_test_ex29_train1_test1.fig -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Fig/dn_dsf_test_ex29_train1_test1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Fig/dn_dsf_test_ex29_train1_test1.png -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Fig/dnvn_dsf_test_ex1_train1_test1.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Fig/dnvn_dsf_test_ex1_train1_test1.fig -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Fig/dnvn_dsf_test_ex1_train1_test1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Fig/dnvn_dsf_test_ex1_train1_test1.png -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Fig/dnvn_du_test_ex39_train2_test1.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Fig/dnvn_du_test_ex39_train2_test1.fig -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Fig/dnvn_du_test_ex39_train2_test1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/Autoencoder-MATLAB/Fig/dnvn_du_test_ex39_train2_test1.png -------------------------------------------------------------------------------- /Autoencoder-MATLAB/FlipAnalytics.m: -------------------------------------------------------------------------------- 1 | function [mean_fidelity, var_fidelity] = FlipAnalytics(psi, p) 2 | % FlipAnalytics provides properties of spin-flip noise on an arbitrary state 3 | % 4 | % in: 5 | % psi: state in the tensor product basis 6 | % p: spin-flip probability per qubit or array of spin-flip probabilities 7 | % out: 8 | % mean_fidelity: mean fidelity of correctly weighted flipped psi with psi (for each p) 9 | % var_fidelity: variance of the fidelity (for each p) 10 | 11 | psi = psi(:); 12 | p = p(:); 13 | dim = length(psi); % dimension of Hilbert space 14 | m = log2(dim); % number of qubits 15 | 16 | % all possible flip combinations binaries2(i,:) 17 | % 1: flip, 0: no flip 18 | binaries1 = dec2bin(0:(dim-1), m); 19 | binaries2 = reshape(str2num(binaries1(:)), dim, m); 20 | 21 | k = sum(binaries2, 2)'; % flip numbers k(i) 22 | probs = p.^k .* (1-p).^(m-k); % flip probabilities probs(:,i) 23 | 24 | flip1 = [0, 1; 1, 0]; % spin flip for one qubit 25 | id = eye(2); 26 | flips = zeros(dim, dim, dim); % flip operators flips(:,:,i) 27 | for s = 1:dim 28 | b = binaries2(s,:); 29 | if b(1) == 0 30 | f = id; 31 | else 32 | f = flip1; 33 | end 34 | for r = 2:m 35 | if b(r) == 0 36 | f = kron(f, id); 37 | else 38 | f = kron(f, flip1); 39 | end 40 | end 41 | flips(:,:,s) = f; 42 | end 43 | 44 | psi_flipped = squeeze(multiprod(flips, psi)); % flipped states psi_flipped(:,i) 45 | fidelities = abs(psi' * psi_flipped).^2; % fidelities(i) of flipped states with original state 46 | 47 | mean_fidelity = sum(probs .* fidelities, 2); 48 | var_fidelity = sum(probs .* (fidelities - mean_fidelity).^2, 2); 49 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/FlipAnalyticsDicke.m: -------------------------------------------------------------------------------- 1 | function [mean_fidelity, var_fidelity] = FlipAnalyticsDicke(m, k, p) 2 | % FlipAnalyticsDicke provides properties of spin-flip noise on Dicke states 3 | % 4 | % in: 5 | % m: number of qubits 6 | % k: number of up spins 7 | % p: spin-flip probability per qubit or array of spin-flip probabilities 8 | % out: 9 | % mean_fidelity: mean Dicke fidelity (for each p) 10 | % var_fidelity: variance of Dicke fidelity (for each p) 11 | 12 | p = p(:); 13 | if k > floor(m/2) % exploit symmetry between Dicke(m,k) and Dicke(m,m-k) 14 | k = m - k; 15 | end 16 | flips = 0:m; 17 | ind = 0:k; 18 | 19 | probs = arrayfun(@(x) nchoosek(m, x), flips) .* p.^flips .* (1-p).^(m-flips); 20 | fids = zeros(1, m+1); 21 | finfids = (arrayfun(@(x) nchoosek(2*x, x) * nchoosek(m - 2*x, k - x), ind) / nchoosek(m, k)).^2; 22 | fids(2 * ind + 1) = finfids; 23 | 24 | mean_fidelity = sum(probs .* fids, 2); 25 | var_fidelity = sum(probs .* (fids - mean_fidelity).^2, 2); 26 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/FlipAnalyticsGHZ.m: -------------------------------------------------------------------------------- 1 | function [mean_fidelity, var_fidelity] = FlipAnalyticsGHZ(m, p) 2 | % FlipAnalyticsGHZ provides properties of spin-flip noise on GHZ states 3 | % 4 | % in: 5 | % m: number of qubits 6 | % p: spin-flip probability per qubit or array of spin-flip probabilities 7 | % out: 8 | % mean_fidelity: mean GHZ fidelity (for each p) 9 | % var_fidelity: variance of GHZ fidelity (for each p) 10 | 11 | mean_fidelity = p.^m + (1 - p).^m ; % probability of zero effective flips 12 | var_fidelity = mean_fidelity .* (1 - mean_fidelity); 13 | 14 | % denoising is expected if zero effective flips is most probable 15 | % this is true for all p < 1/2 16 | % for p = 1/2, any effective flipped state has the same probability 17 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/GHZ.m: -------------------------------------------------------------------------------- 1 | function psi = GHZ(m, phi) 2 | % GHZ creates ghz states with relative phases 3 | % 4 | % in: 5 | % m: number of qubits 6 | % phi (optional, default = 0): array of relative phases 7 | % out: 8 | % psi: psi(:,j) is the state (up + exp(i*phi(j)) down) / sqrt(2) 9 | % in the tensor product basis 10 | 11 | if nargin < 2 12 | phi = 0; 13 | end 14 | 15 | psi = zeros(2^m, length(phi)); 16 | psi(1,:) = 1; 17 | psi(end,:) = exp(1i*phi); 18 | psi = psi / sqrt(2); 19 | end 20 | -------------------------------------------------------------------------------- /Autoencoder-MATLAB/GeneralizationTask.m: -------------------------------------------------------------------------------- 1 | %Computes all Cost functions in Generalization Task 2 | 3 | function CList = GeneralizationTask(phi_in,phi_out,U,M) 4 | 5 | dim = 2^M(1); 6 | %size(phi_in,2) = N_NumTrain can be bigger than dim 7 | 8 | CList= zeros(1,dim); 9 | for j = 1:dim 10 | phi_in_use = phi_in(:,1:j); 11 | phi_out_use = phi_out(:,1:j); 12 | 13 | %Specify good iteration number and lambda 14 | [x,z] = TrainNetwork(phi_in_use,phi_out_use,U,M,1.5,350); 15 | CList(j) = CostNetwork(phi_in,phi_out,x,M); 16 | end 17 | 18 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/How to use this program.txt: -------------------------------------------------------------------------------- 1 | You will need the MATLAB Toolbox QETLAB ( see http://www.qetlab.com/Main_Page). The program uses its implementation of the PartialTrace and the Swap Operation. 2 | 3 | The program can implement general Network configurations. These configurations are stored in the M array. 4 | A Network with two layers with two Neurons each is given by M = [2,2]. 5 | A Network with three layers with two Neurons in the input and output layer and three Neurons in the hidden layer is given by M =[2,3,2]. 6 | 7 | First Initilize the Network by generating an array with random unitaries for a given network M with "QuickInitilizer.m". 8 | The unitaries are stored in the cell array U. U{k}(:,:,j) is then the corresponding unitary of the jth neuron in the kth layer. 9 | 10 | Then Train the Network with "TrainNetwork.m". 11 | 12 | You will need an array of training input and output states phi_in and phi_out, where phi_in(:,j) is the jth input vector of your training sample. -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Noisydata.m: -------------------------------------------------------------------------------- 1 | %Calculates Costfunctions for Noisy data Plot. phi_in_start and 2 | %phi_out_start should be RandomUnitaryTrainingData 3 | 4 | function CList = Noisydata(phi_in_start,phi_out_start,U,M,s) 5 | %s is the number of steps between each point 6 | 7 | N_NumTrain = size(phi_in_start,2); 8 | 9 | dim = 2^M(1); 10 | 11 | 12 | N_iter = N_NumTrain/s; 13 | % N_iter should be integer 14 | 15 | 16 | CList = zeros(1,N_iter); 17 | phi_in = phi_in_start; 18 | phi_out = phi_out_start; 19 | [phi_in_noisy,phi_out_noisy] = Randomtrainingdata(N_NumTrain,dim); 20 | 21 | for j = 1:N_iter+1 22 | 23 | %Specify good iteration number and lambda 24 | x = TrainNetwork(phi_in,phi_out,U,M,1.5,250); 25 | CList(j) = CostNetwork(phi_in_start,phi_out_start,x,M); 26 | if j < N_iter+1 27 | List = randperm(N_NumTrain); 28 | phi_in = phi_in_start(:,List); 29 | phi_out = phi_out_start(:,List); 30 | 31 | List = randperm(N_NumTrain); 32 | phi_in_noisy = phi_in_noisy(:,List); 33 | phi_out_noisy = phi_out_noisy(:,List); 34 | 35 | phi_in(:,1:s*j) = phi_in_noisy(:,1:s*j); 36 | phi_out(:,1:s*j) = phi_out_noisy(:,1:s*j); 37 | end 38 | 39 | end 40 | 41 | 42 | 43 | end 44 | -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Paperplot1.m: -------------------------------------------------------------------------------- 1 | 2 | savename1 = 'pp1_a'; 3 | load('Dat/plot_dsf_test_ex8_train1_test1', 'noise', 'fid', 'sdv') 4 | fid1 = fid; 5 | sdv1 = sdv; 6 | load('Dat/plot_dsf_test_ex10_train6_test1', 'fid', 'sdv') 7 | noise1 = noise; 8 | fid1 = cat(2, fid1, fid{end}); 9 | sdv1 = cat(2, sdv1, sdv{end}); 10 | legend1 = ["expected noise", "noisy sample", "[4,2,1,2,4] denoised", "[4,1,4,1,4] denoised"]; 11 | 12 | PlotDenoisingVsNoise(noise1, fid1,... 13 | 'sdv_fidelity', sdv1, 'savename', savename1, 'legend', legend1, 'lposition', [0.31,0.21],... 14 | 'xlabel', 'spin-flip probability p', 'ylabel', 'fidelity with GHZ-0',... 15 | 'plotstyle', {{"+",'MarkerSize', 5, 'LineWidth', 1.5, 'CapSize', 0},... 16 | {".", 'MarkerSize', 25, 'LineWidth', 1.5},... 17 | {"o", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 20},... 18 | {"x", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 15}}) 19 | 20 | savename2 = 'pp1_b'; 21 | load('Dat/plot_du_test_ex8_train1_test1', 'noise', 'fid', 'sdv') 22 | fid2 = fid; 23 | sdv2 = sdv; 24 | load('Dat/plot_du_test_ex10_train3_test1', 'fid', 'sdv') 25 | noise2 = noise; 26 | fid2 = cat(2, fid2, fid{end}); 27 | sdv2 = cat(2, sdv2, sdv{end}); 28 | legend2 = ["noisy", "[4,2,1,2,4] \newlinedenoised", "[4,1,4,1,4] \newlinedenoised"]; 29 | 30 | PlotDenoisingVsNoise(noise2, fid2,... 31 | 'sdv_fidelity', sdv2, 'savename', savename2, 'legend', legend2, 'lposition', [0.25,0.235],... 32 | 'xlabel', 'noise strength q', 'ylabel', 'fidelity with GHZ-0',... 33 | 'plotstyle', {{".", 'MarkerSize', 25, 'LineWidth', 1.5, 'Color', [0.85,0.325,0.098]},... 34 | {"o", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 20, 'Color', [0.929,0.694,0.125]},... 35 | {"x", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 15, 'Color', [0.494,0.184,0.556]}}) -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Paperplot2.m: -------------------------------------------------------------------------------- 1 | 2 | savename1 = 'pp2_a'; 3 | load('Dat/plot_dsf_test_ex9_train2_test1', 'noise', 'fid', 'sdv') 4 | fid1 = fid; 5 | sdv1 = sdv; 6 | noise1 = noise; 7 | legend1 = ["expected noise", "noisy sample", "[4,2,1,2,4] sparse \newlinedenoised"]; 8 | 9 | PlotDenoisingVsNoise(noise1, fid1,... 10 | 'sdv_fidelity', sdv1, 'savename', savename1, 'legend', legend1, 'lposition', [0.28,0.21],... 11 | 'xlabel', 'spin-flip probability p', 'ylabel', 'fidelity with GHZ-0',... 12 | 'plotstyle', {{"+",'MarkerSize', 5, 'LineWidth', 1.5, 'CapSize', 0},... 13 | {".", 'MarkerSize', 25, 'LineWidth', 1.5},... 14 | {"o", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 20}}) 15 | 16 | savename2 = 'pp2_b'; 17 | load('Dat/plot_du_test_ex9_train1_test1', 'noise', 'fid', 'sdv') 18 | fid2 = fid; 19 | sdv2 = sdv; 20 | noise2 = noise; 21 | legend2 = ["noisy", "[4,2,1,2,4] sparse \newlinedenoised"]; 22 | 23 | PlotDenoisingVsNoise(noise2, fid2,... 24 | 'sdv_fidelity', sdv2, 'savename', savename2, 'legend', legend2, 'lposition', [0.28,0.19],... 25 | 'xlabel', 'noise strength q', 'ylabel', 'fidelity with GHZ-0',... 26 | 'plotstyle', {{".", 'MarkerSize', 25, 'LineWidth', 1.5, 'Color', [0.85,0.325,0.098]},... 27 | {"o", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 20, 'Color', [0.929,0.694,0.125]}}) 28 | -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Paperplot4.m: -------------------------------------------------------------------------------- 1 | 2 | savename1 = 'pp4_b'; 3 | load('Dat/plot_dsf_test_ex10_train13_test1', 'noise', 'fid', 'sdv') 4 | fid1 = {fid{2}, fid{1}, fid{3}}; 5 | sdv1 = {sdv{2}, sdv{1}, sdv{3}}; 6 | noise1 = noise; 7 | legend1 = ["noisy sample", "expected noise", "[4,1,4,1,4] denoised"]; 8 | 9 | PlotDenoisingVsNoise(noise1, fid1,... 10 | 'sdv_fidelity', sdv1, 'savename', savename1, 'legend', legend1, 'lposition', [0.745,0.852],... 11 | 'xlabel', 'spin-flip probability p', 'ylabel', 'fidelity with GHZ-0',... 12 | 'plotstyle', {{".", 'MarkerSize', 25, 'LineWidth', 1.5, 'Color', [0.85,0.325,0.098]},... 13 | {"+",'MarkerSize', 5, 'LineWidth', 1.5, 'CapSize', 0, 'Color', [0, 0.447, 0.741]},... 14 | {"x", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 15, 'Color', [0.494,0.184,0.556]}}) 15 | 16 | ax = gca; 17 | ax.XLim = [0.325, 0.49]; 18 | ax.XTick = [0.35, 0.4, 0.45]; 19 | savefig(strcat('Fig/dnvn_', savename1, '.fig')) 20 | saveas(gcf, strcat('Fig/dnvn_', savename1), 'png') 21 | saveas(gcf, strcat('Fig/dnvn_', savename1), 'epsc') -------------------------------------------------------------------------------- /Autoencoder-MATLAB/PlotCost.m: -------------------------------------------------------------------------------- 1 | function PlotCost(cost, varargin) 2 | % PlotCost plots cost arrays as a function of training round 3 | % 4 | % in: 5 | % cost: cost array or cell of cost arrays 6 | % optional in as name/value pairs (function(..., 'name', value, ...)): 7 | % savename: plots are saved at 'Fig/cost_savename'; default is no saving 8 | % legend: a cell of legend labels; 9 | % default: 1, 2,... if more than one data set is drawn 10 | % title: a plot title; default is no title 11 | 12 | if rem(length(varargin), 2) == 1 % test that optional input is paired 13 | error('Provide the optional input arguments as name/value pairs.') 14 | end 15 | varargin = cell2struct(varargin(2:2:end), varargin(1:2:end), 2); 16 | 17 | if ~iscell(cost) % for a single data set: ensure cost is a cell 18 | cost = {cost}; 19 | end 20 | num = length(cost); 21 | 22 | figure % plot 23 | hold on 24 | 25 | for i = 1:num 26 | plot(cost{i}, 'LineWidth', 2.5) 27 | end 28 | 29 | % set plot properties 30 | if isfield(varargin, 'legend') || num > 1 31 | if isfield(varargin, 'legend') 32 | leg = varargin.('legend'); 33 | else 34 | leg = string(1:num); 35 | end 36 | legend(leg, 'Location', 'eastoutside') 37 | end 38 | ax = gca; 39 | ax.YLim = [0, 1.1]; 40 | ax.LineWidth = 1.5; 41 | ax.FontSize = 16; % ticks; if not explicitly set: labels, legend 42 | xlabel('iteration') 43 | ylabel('fidelity') 44 | if isfield(varargin, 'title') 45 | title(varargin.('title'), 'FontWeight', 'normal') 46 | end 47 | hold off 48 | 49 | if isfield(varargin, 'savename') % save 50 | savename = varargin.('savename'); 51 | savefig(strcat('Fig/cost_', savename, '.fig')) 52 | saveas(gcf, strcat('Fig/cost_', savename), 'png') 53 | saveas(gcf, strcat('Fig/cost_', savename), 'epsc') 54 | end 55 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/PlotDenoising.m: -------------------------------------------------------------------------------- 1 | function PlotDenoising(fidelity_in, fidelity_out, varargin) 2 | % PlotDenoising plots the ideal state fidelity of noisy and denoised states 3 | % 4 | % in: 5 | % fidelity_in: array of noisy state fidelities 6 | % fidelity_out: array of denoised state fidelities 7 | % optional in as name/value pairs (function(..., 'name', value, ...)): 8 | % savename: plots are saved at 'Fig/dn_savename'; default is no saving 9 | % title: a plot title; default is no title 10 | % ylabel: label string; default is 'fidelity' 11 | % legend: a cell of legend labels; 12 | % default: {'noisy', 'denoised'} 13 | % lposition: [left, bottom] array for legend positioning; 14 | % default is 'best' 15 | 16 | if rem(length(varargin), 2) == 1 % test that optional input is paired 17 | error('Provide the optional input arguments as name/value pairs.') 18 | end 19 | varargin = cell2struct(varargin(2:2:end), varargin(1:2:end), 2); 20 | 21 | figure % plot 22 | hold on 23 | 24 | plot(fidelity_in, "o", 'MarkerSize', 4, 'LineWidth', 1.5, 'Color', [0.85,0.325,0.098], 'MarkerFaceColor', [0.85,0.325,0.098]) 25 | plot(fidelity_out, "o", 'MarkerSize', 4, 'LineWidth', 1.5, 'Color', [0.929,0.694,0.125]) 26 | 27 | % set plot properties 28 | if isfield(varargin, 'legend') 29 | label = varargin.('legend'); 30 | else 31 | label = {'noisy', 'denoised'}; 32 | end 33 | if isfield(varargin, 'lposition') 34 | pos = {'Position', cat(2, varargin.('lposition'), [0,0])}; 35 | else 36 | pos = {}; 37 | end 38 | legend(label{:}, 'Orientation', 'horizontal', 'NumColumns', 1,... 39 | 'Location', 'best', pos{:}) 40 | ax = gca; 41 | ax.YLim = [0, 1.1]; 42 | ax.LineWidth = 1.5; 43 | ax.FontSize = 12; % ticks; if not explicitly set: labels, legend, title 44 | xlabel('test no') 45 | if isfield(varargin, 'ylabel') 46 | ylabel(varargin.('ylabel')) 47 | else 48 | ylabel('fidelity') 49 | end 50 | if isfield(varargin, 'title') 51 | title(varargin.('title'), 'FontWeight', 'normal') 52 | end 53 | hold off 54 | 55 | if isfield(varargin, 'savename') % save 56 | savename = varargin.('savename'); 57 | savefig(strcat('Fig/dn_', savename, '.fig')) 58 | saveas(gcf, strcat('Fig/dn_', savename), 'png') 59 | saveas(gcf, strcat('Fig/dn_', savename), 'epsc') 60 | end 61 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/PlotDenoisingVsNoise.m: -------------------------------------------------------------------------------- 1 | function PlotDenoisingVsNoise(noise, mean_fidelity, varargin) 2 | % PlotDenoisingVsNoise plots mean fidelities as a function of noise strength 3 | % 4 | % in: 5 | % noise: an array of noise strengths or a cell of noise strength arrays 6 | % mean_fidelity: corr. array of mean fidelities or a cell of arrays; 7 | % if all cell elements correspond to one noise array, 8 | % noise can be provided as one array 9 | % optional in as name/value pairs (function(..., 'name', value, ...)): 10 | % sdv_fidelity: an array or cell of fidelity standard deviations 11 | % savename: plots are saved at 'Fig/dnvn_savename'; default is no saving 12 | % legend: a cell of legend labels; 13 | % default: 1, 2,... if more than one data set is drawn 14 | % plotstyle: a cell of plot styles as input to the errorbar function; 15 | % combine more than one prescription per plot style into a cell; 16 | % if only one data set is plotted, plotstyle can also be 17 | % a string or a cell directly containing several prescriptions; 18 | % default: {".", 'MarkerSize', 25, 'LineWidth', 1.5} 19 | % xlabel: label string; default is 'noise strength' 20 | % lposition: [left, bottom] array for legend positioning; 21 | % default is 'southwest' 22 | 23 | if rem(length(varargin), 2) == 1 % test that optional input is paired 24 | error('Provide the optional input arguments as name/value pairs.') 25 | end 26 | varargin = cell2struct(varargin(2:2:end), varargin(1:2:end), 2); 27 | 28 | if ~iscell(mean_fidelity) % for a single data set: ensure mean_fidelity is a cell 29 | mean_fidelity = {mean_fidelity}; 30 | end 31 | num = length(mean_fidelity); 32 | 33 | if isfield(varargin, 'sdv_fidelity') % define error bars 34 | err = varargin.('sdv_fidelity'); 35 | if ~iscell(err) % for a single data set: ensure err is a cell 36 | err = {err}; 37 | end 38 | else 39 | err = cellfun(@(x) NaN*x, mean_fidelity, 'UniformOutput', 0); 40 | end 41 | if isfield(varargin, 'plotstyle') % define plot styles 42 | plotstyle = varargin.('plotstyle'); 43 | if num == 1 % flexible input parsing for single data set 44 | if iscell(plotstyle) 45 | if ~iscell(plotstyle{1}) 46 | plotstyle = {plotstyle}; 47 | end 48 | else 49 | plotstyle = {{plotstyle}}; 50 | end 51 | else 52 | if iscell(plotstyle) 53 | for i = 1:num % flexible input parsing for multiple data sets 54 | istyle = plotstyle{i}; 55 | if ~iscell(istyle) 56 | plotstyle{i} = {istyle}; 57 | end 58 | end 59 | else 60 | error('The plotstyle has to be a cell of styles for each data set.') 61 | end 62 | end 63 | else 64 | plotstyle = cell(1,num); % default plot style 65 | [plotstyle{:}] = deal({".", 'MarkerSize', 25, 'LineWidth', 1.5}); 66 | end 67 | 68 | figure % plot 69 | hold on 70 | 71 | if iscell(noise) 72 | for i = 1:num 73 | errorbar(noise{i}, mean_fidelity{i}, err{i}, plotstyle{i}{:}) 74 | end 75 | else 76 | for i = 1:num 77 | errorbar(noise, mean_fidelity{i}, err{i}, plotstyle{i}{:}) 78 | end 79 | end 80 | 81 | % set plot properties 82 | if isfield(varargin, 'legend') || num > 1 83 | if isfield(varargin, 'legend') 84 | leg = varargin.('legend'); 85 | else 86 | leg = string(1:num); 87 | end 88 | if isfield(varargin, 'lposition') 89 | lpos = varargin.('lposition'); 90 | legend(leg, 'Position', [lpos(1),lpos(2),0,0]) 91 | else 92 | legend(leg, 'Location', 'southwest') 93 | end 94 | end 95 | ax = gca; 96 | ax.YLim = [0, 1.15]; 97 | ax.LineWidth = 1.5; 98 | ax.FontSize = 12; % ticks; if not explicitly set: labels, legend 99 | if isfield(varargin, 'xlabel') 100 | xlabel(varargin.('xlabel')) 101 | else 102 | xlabel('noise strength') 103 | end 104 | if isfield(varargin, 'ylabel') 105 | ylabel(varargin.('ylabel')) 106 | else 107 | ylabel('mean fidelity') 108 | end 109 | hold off 110 | 111 | if isfield(varargin, 'savename') % save 112 | savename = varargin.('savename'); 113 | savefig(strcat('Fig/dnvn_', savename, '.fig')) 114 | saveas(gcf, strcat('Fig/dnvn_', savename), 'png') 115 | saveas(gcf, strcat('Fig/dnvn_', savename), 'epsc') 116 | end 117 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/QuickInitilizer.m: -------------------------------------------------------------------------------- 1 | function U = QuickInitilizer(M, varargin) 2 | % This functions quickly initializes a set of random unitaries for the 3 | % network with configuration M. 4 | % 5 | % optional in as name/value pairs (function(..., 'name', value, ...)): 6 | % sparse: cell array S defining the sparsity of the neural network; 7 | % for the k-th layer in M, the j-th neuron in this layer, 8 | % and its connection to the i-th neuron in the (k-1)-th layer, 9 | % S{k-1}(j,i) is either zero or one, where 1 means connected; 10 | % default is a fully connected network 11 | % out: 12 | % The unitaries for each layer are stored in the cell array U. 13 | % U{k}(:,:,j) is the unitary belonging to the jth neuron in the kth layer. 14 | % If sparse, U{k}(:,:,j) acts as an identity on disconnected qubits. 15 | 16 | if rem(length(varargin), 2) == 1 % test that optional input is paired 17 | error('Provide the optional input arguments as name/value pairs.') 18 | end 19 | varargin = cell2struct(varargin(2:2:end), varargin(1:2:end), 2); 20 | 21 | N_NumLay = size(M,2); 22 | 23 | if ~isfield(varargin, 'sparse') % fully connected 24 | for k = 2:N_NumLay 25 | for j = 1:M(k) 26 | U{k}(:,:,j) = Randomunitary(2^(M(k-1)+1)); 27 | end 28 | end 29 | else 30 | sparsity = varargin.('sparse'); % sparse 31 | for k = 2:N_NumLay 32 | for j = 1:M(k) 33 | NumBonds = M(k-1); % number of connections if fully connected 34 | bonds = 1:NumBonds; 35 | cut = bonds(~sparsity{k-1}(j,:)); % indices of connections to cut 36 | NumCut = length(cut); % number of connections to cut 37 | % random unitary acting on (NumBonds-NumCut+1) qubits 38 | % tensored with identities on NumCut qubits: 39 | Ukj = kron(Randomunitary(2^(NumBonds-NumCut+1)), eye(2^NumCut)); 40 | for i = 1:NumCut % swap identities to disconnected qubits 41 | Ukj = Swap(Ukj, [cut(i), NumBonds+2-i], 2*ones(1, NumBonds+1)); 42 | end 43 | U{k}(:,:,j) = Ukj; 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /Autoencoder-MATLAB/RandomUnitary1.m: -------------------------------------------------------------------------------- 1 | function U = RandomUnitary1(dim,t,n) 2 | %RandomUnitary1(deviation) creates a dim-dimensional unitary close to identiry. 3 | %For t=0 the answer is identity, for large enough t 4 | %(for practical purpouses, t~1) 5 | %the answer is a unitary sampled from Haar distribution. 6 | %The error to Texp(\int_0^t i \pi H(t) dt ) with random H(t) scales as 1/sqrt(n). 7 | 8 | U = BrownianCircuit(dim,n,sqrt(1/(n*dim))*2*pi*t); 9 | end 10 | -------------------------------------------------------------------------------- /Autoencoder-MATLAB/RandomUnitaryTrainingsData.m: -------------------------------------------------------------------------------- 1 | %Generates an array of random trainings data, where for each the output 2 | %state is the image of the input state under a given (randomly chosenn) 3 | %unitary 4 | function [phi_in,phi_out,U] = RandomUnitaryTrainingsData (n,m) 5 | 6 | phi_in = randn(m,n) + i* randn(m,n); 7 | 8 | for j = 1:n 9 | phi_in(: ,j) = (phi_in(: ,j))/norm(phi_in(: ,j)); 10 | end 11 | 12 | U = Randomunitary(m); 13 | 14 | phi_out = zeros(m,n); 15 | 16 | for j =1:n 17 | 18 | phi_out(:,j) = U *phi_in(:,j); 19 | end 20 | 21 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Randomtrainingdata.m: -------------------------------------------------------------------------------- 1 | %Generates an array of random input and output vectors 2 | function [phi_in,phi_out] = Randomtrainingdata(n,m) 3 | 4 | phi_in = randn(m,n) + i*randn(m,n); 5 | 6 | for j = 1:n 7 | phi_in(: ,j) = (phi_in(: ,j))/norm(phi_in(: ,j)); 8 | end 9 | 10 | phi_out = randn(m,n) + i*randn(m,n); 11 | 12 | for j = 1:n 13 | phi_out(: ,j) = (phi_out(: ,j))/norm(phi_out(: ,j)); 14 | end 15 | 16 | end -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Randomunitary.m: -------------------------------------------------------------------------------- 1 | %Creates a random unitary on \mathbb{C}^N 2 | function U = Randomunitary(N) 3 | 4 | U = zeros(N); 5 | 6 | U(:,1) = randn(N,1) + i*randn(N,1); 7 | U(:,1) = U(:,1) / norm(U(:,1)); 8 | for j= 2:N 9 | 10 | U(:,j) = randn(N,1) + i*randn(N,1); 11 | for k = 1:j-1 12 | psi = U(:,j); 13 | U(:,j) = U(:,j) - dot(U(:,k),psi)*U(:,k); 14 | end 15 | U(:,j) = U(:,j)/norm(U(:,j)); 16 | end 17 | 18 | 19 | end 20 | 21 | -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Resub_Paperplot1.m: -------------------------------------------------------------------------------- 1 | 2 | savename1 = 'resub_pp1_a'; 3 | load('Dat/plot_dsf_test_ex36_train4_test1', 'noise', 'fid', 'sdv') 4 | fid1 = fid; 5 | sdv1 = sdv; 6 | load('Dat/plot_dsf_test_ex31_train2_test2', 'fid', 'sdv') 7 | noise1 = noise; 8 | fid1 = cat(2, fid1, fid{end}); 9 | sdv1 = cat(2, sdv1, sdv{end}); 10 | legend1 = ["expected noise", "noisy sample", "[3,2,1,2,3] denoised", "[3,1,3,1,3] denoised"]; 11 | 12 | PlotDenoisingVsNoise(noise1, fid1,... 13 | 'sdv_fidelity', sdv1, 'savename', savename1, 'legend', legend1,... % 'lposition', [0.306,0.207],... 14 | 'xlabel', 'spin-flip probability p', 'ylabel', 'fidelity with W',... 15 | 'plotstyle', {{"+",'MarkerSize', 5, 'LineWidth', 1.5, 'CapSize', 0},... 16 | {".", 'MarkerSize', 25, 'LineWidth', 1.5},... 17 | {"o", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 20},... 18 | {"x", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 15}}) 19 | 20 | savename2 = 'resub_pp1_b'; 21 | load('Dat/plot_du_test_ex36_train1_test1', 'noise', 'fid', 'sdv') 22 | fid2 = fid; 23 | sdv2 = sdv; 24 | load('Dat/plot_du_test_ex31_train1_test2', 'fid', 'sdv') 25 | noise2 = noise; 26 | fid2 = cat(2, fid2, fid{end}); 27 | sdv2 = cat(2, sdv2, sdv{end}); 28 | legend2 = ["noisy", "[3,2,1,2,3] \newlinedenoised", "[3,1,3,1,3] \newlinedenoised"]; 29 | % legend2 = ["noisy", "[3,2,1,2,3] denoised", "[3,1,3,1,3] denoised"]; 30 | 31 | PlotDenoisingVsNoise(noise2, fid2,... 32 | 'sdv_fidelity', sdv2, 'savename', savename2, 'legend', legend2, 'lposition', [0.247,0.23],... 33 | 'xlabel', 'noise strength q', 'ylabel', 'fidelity with W',... 34 | 'plotstyle', {{".", 'MarkerSize', 25, 'LineWidth', 1.5, 'Color', [0.85,0.325,0.098]},... 35 | {"o", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 20, 'Color', [0.929,0.694,0.125]},... 36 | {"x", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 15, 'Color', [0.494,0.184,0.556]}}) 37 | -------------------------------------------------------------------------------- /Autoencoder-MATLAB/Resub_Paperplot2.m: -------------------------------------------------------------------------------- 1 | 2 | savename2 = 'resub_pp2'; 3 | load('Dat/plot_dp_test_ex8_train4_test3', 'noise', 'fid', 'sdv') 4 | fid2 = fid; 5 | sdv2 = sdv; 6 | load('Dat/plot_dp_test_ex10_train5_test2', 'fid', 'sdv') 7 | noise2 = noise; 8 | fid2 = cat(2, fid2, fid{end}); 9 | sdv2 = cat(2, sdv2, sdv{end}); 10 | % legend2 = ["noisy", "[4,2,1,2,4] \newlinedenoised", "[4,1,4,1,4] \newlinedenoised"]; 11 | legend2 = ["noisy", "[4,2,1,2,4] denoised", "[4,1,4,1,4] denoised"]; 12 | 13 | PlotDenoisingVsNoise(noise2, fid2,... 14 | 'sdv_fidelity', sdv2, 'savename', savename2, 'legend', legend2,... 15 | 'xlabel', 'phase spread $\sigma / \pi$', 'ylabel', 'fidelity with GHZ-0',... 16 | 'plotstyle', {{".", 'MarkerSize', 25, 'LineWidth', 1.5, 'Color', [0.85,0.325,0.098]},... 17 | {"o", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 20, 'Color', [0.929,0.694,0.125]},... 18 | {"x", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 15, 'Color', [0.494,0.184,0.556]}}) 19 | % 'lposition', [0.247,0.23], -------------------------------------------------------------------------------- /Autoencoder-MATLAB/SpectralRange.m: -------------------------------------------------------------------------------- 1 | function range = SpectralRange(A) 2 | %Outputs a spectral gap of a matrix A. 3 | 4 | range = norm(norm(A)*eye(size(A,1)) - A); -------------------------------------------------------------------------------- /Autoencoder-MATLAB/SpinFlipNoise.m: -------------------------------------------------------------------------------- 1 | function [psi_noisy, varargout] = SpinFlipNoise(psi, n, p) 2 | % SpinFlipNoise applies n times spin-flip noise to an m-qubit state psi 3 | % with spin-flip probability p per qubit 4 | % 5 | % in: 6 | % psi: noiseless m-qubit state in tensor product basis as column vector 7 | % n: number of noise realizations 8 | % p: spin-flip probability per qubit, maximal physical value is 0.5 9 | % out: 10 | % psi_noisy: psi_noisy(:,i) is the ith realization of a noisy psi 11 | % varargout: 12 | % {1}: n-element logical array v 13 | % with v(i)= 1 if psi_noisy(:,i) experienced only 0 or 1 spin-flips 14 | 15 | if p > 0.5 16 | error('Spin-flip probability per qubit greater than 0.5 is unphysical.') 17 | end 18 | 19 | dim = length(psi); % dimension of Hilbert space 20 | m = log2(dim); % number of qubits 21 | 22 | % define flips(:,:,i) as flip of ith spin 23 | flip1 = [0, 1; 1, 0]; % spin flip for one qubit 24 | id = eye(2); 25 | flips = zeros(dim, dim, m); 26 | for i = 1:m 27 | f = flip1; 28 | for j = 1:(i-1) 29 | f = kron(id, f); 30 | end 31 | for j = (i+1):m 32 | f = kron(f, id); 33 | end 34 | flips(:,:,i) = f; 35 | end 36 | 37 | % for every noise realization psi_noisy(:,i) and every qubit j 38 | % draw random number r(j) from uniform distribution in (0, 1) 39 | % and apply jth spin flip with probability p, i.e. if r(j) <= p 40 | psi_noisy = zeros(dim, n); 41 | varargout = zeros(n,1); 42 | for i = 1:n 43 | r = rand(m,1); % random numbers 44 | pn = psi; 45 | for j = 1:m 46 | if r(j) <= p 47 | pn = flips(:,:,j) * pn; % apply spin flip 48 | end 49 | end 50 | psi_noisy(:,i) = pn; 51 | nflips = (r <= p); 52 | if sum(nflips) <= 1 % maximally one spin flip 53 | varargout(i) = 1; 54 | end 55 | end 56 | varargout = {logical(varargout)}; 57 | end 58 | -------------------------------------------------------------------------------- /Autoencoder-MATLAB/TestRandomUnitary1.m: -------------------------------------------------------------------------------- 1 | %this script tests RandomUnitary1 2 | N=50; 3 | M=60; 4 | hold on 5 | for l=1:3 6 | for i=1:3 7 | x=zeros(1,M); 8 | for k=1:M 9 | for j= 1:N 10 | x(k)=x(k)+Fidelity(GHZ(l,0), RandomUnitary1(2^l,1.5*k/M,20*i*M/k)*GHZ(l,0)); 11 | end 12 | x(k)=x(k)/N; 13 | end 14 | plot(x) 15 | end 16 | end 17 | hold off -------------------------------------------------------------------------------- /Autoencoder-MATLAB/TrainNetwork.m: -------------------------------------------------------------------------------- 1 | function [U,CList] = TrainNetwork(phi_in,phi_out,U,M,lambda,iter,varargin) 2 | % Trains the Network and gives out the array with all trained unitaries in U 3 | % and an array CList with all Cost functions while training 4 | % 5 | % optional in as name/value pairs (function(..., 'name', value, ...)): 6 | % sparse: cell array S defining the sparsity of the neural network; 7 | % for the k-th layer in M, the j-th neuron in this layer, 8 | % and its connection to the i-th neuron in the (k-1)-th layer, 9 | % S{k-1}(j,i) is either zero or one, where 1 means connected; 10 | % default is a fully connected network 11 | % momentum: a number that is a momentum coefficient in a 12 | % gradient descent with momentum. 13 | % RMSprop: a number that is a memory coefficient in the RMSprop 14 | % gradient descent algorithm. 15 | % Cannot be used with Adam or Nadam. 16 | % Adam: a number that is a second momentum memory coefficient in the Adam 17 | % gradient descent algorithm. The first momentum coefficient in the Adam 18 | % is the number in the field 'momentum'. 19 | % Can not be used with RMSprop or Nadam. 20 | % Nadam: a number that is a second momentum memory coefficient in the Nadam 21 | % gradient descent algorithm. The first momentum coefficient in the Nadam 22 | % is the number in the field 'momentum'. 23 | % Can not be used with RMSprop or Adam. 24 | % A good overview of gradient descent algorithms can be found at 25 | % http://ruder.io/optimizing-gradient-descent/ 26 | % 27 | % out: 28 | % U: cell array of trained unitaries, 29 | % U{k}(:,:,j) belongs to the j-th neuron in the k-th layer; 30 | % if sparse, U{k}(:,:,j) acts as an identity on disconnected qubits 31 | % CList: array of cost functions for each training round 32 | 33 | %if_RMSprop = false; 34 | momentum_coefficient = 0; 35 | if_RMSprop = false; 36 | if_Adam = false; 37 | if_Nadam = false; 38 | 39 | if ~isempty(varargin) 40 | if rem(length(varargin), 2) == 1 % test that optional input is paired 41 | error('Provide the optional input arguments as name/value pairs.') 42 | end 43 | varargin = cell2struct(varargin(2:2:end), varargin(1:2:end), 2); 44 | 45 | if isfield(varargin, 'momentum') % get momentum coefficient 46 | momentum_coefficient = varargin.('momentum'); 47 | end 48 | if isfield(varargin, 'RMSprop') % define RMSprop coefficient 49 | if_RMSprop = true; 50 | RMSprop_coefficient = varargin.('RMSprop'); 51 | else 52 | if isfield(varargin, 'Adam') % define RMSprop coefficient 53 | if_Adam = true; 54 | RMSprop_coefficient = varargin.('Adam'); 55 | else 56 | if isfield(varargin, 'Nadam') % define RMSprop coefficient 57 | if_Nadam = true; 58 | RMSprop_coefficient = varargin.('Nadam'); 59 | end 60 | end 61 | end 62 | 63 | % check_sparse = cellfun(@(c) ischar(c) && strcmp(c, 'sparse'), varargin); 64 | % ind_sparse = find(check_sparse); 65 | % if ~isempty(ind_sparse) 66 | % sparse = true; 67 | % sparsity = varargin{ind_sparse+1}; 68 | % sparsity = cellfun(@(c) logical(c), sparsity, 'uo', false); 69 | % varargin = varargin([1:(ind_sparse-1), (ind_sparse+2):end]); 70 | % end 71 | end 72 | 73 | %iter: number of iterations the network trains (update all unitaries) 74 | eps= 0.1; 75 | 76 | N_NumTrain = size(phi_in,2); 77 | N_NumLay = size(M,2); 78 | 79 | CList = [CostNetwork(phi_in,phi_out,U,M)]; 80 | 81 | %Update the Unitaries iter time 82 | K ={}; 83 | PrevK ={}; %PrevK is the previous iteration of K update matrices, needed for momentum gradient descent. 84 | RenormL = {}; %RenormL is a list constant that renormalizes the learning rate for each K update matrix. 85 | 86 | for k = 2:N_NumLay 87 | if (if_RMSprop || momentum_coefficient || if_Adam || if_Nadam) 88 | PrevK{k}=zeros(2^(M(k-1)+1),2^(M(k-1)+1),M(k)); 89 | if (if_RMSprop || if_Adam || if_Nadam) 90 | RenormL{k} = zeros(M(k)); 91 | end 92 | end 93 | end 94 | 95 | for round=2:iter 96 | %UpdateMatrix = {}; % UpdateMatrix is the matrix that include the momentum and constant renormalization terms. 97 | 98 | %Generating all K Update Matrices 99 | for x = 1:N_NumTrain 100 | 101 | for k = 2:N_NumLay 102 | %Initilize a state to calculate state of left side of the Commutator in the Update Matrix M 103 | %i.e. the one coming from the \mathcal{E} or "ApplyLayer" Channel. 104 | if x == 1 105 | K{k} = zeros(2^(M(k-1)+1),2^(M(k-1)+1),M(k)); 106 | end 107 | 108 | if k == 2 109 | rho_left_prev = phi_in(:,x)*phi_in(:,x)'; 110 | else 111 | rho_left_prev = ApplyLayer(rho_left_prev,U{k-1},M(k-1),M(k-2)); 112 | end 113 | rho_left = kron(rho_left_prev,[1;zeros(2^M(k)-1,1)]*[1;zeros(2^M(k)-1,1)]'); 114 | 115 | for j = 1:M(k) 116 | %Initilize a state to calculate the state of the right hand side 117 | %of the Commutator in the Update Matrix M, i.e. the one coming 118 | %from the conjugate F Channel. 119 | if k==2 && j==1 120 | for k_1 = 2:N_NumLay 121 | k_2 = N_NumLay -k_1 +2; 122 | if k_2 == N_NumLay 123 | rho_right_prev = phi_out(:,x)*phi_out(:,x)'; 124 | else 125 | rho_right_prev = FChannel(rho_right_prev,U{k_2+1},M(k_2 +1),M(k_2)); 126 | end 127 | rho_right{k_2} = kron(eye(2^M(k_2-1)),rho_right_prev); 128 | for j_1 = 1:M(k_2) 129 | j_2 = M(k_2) -j_1 +1; 130 | V = Swap(kron(U{k_2}(:,:,j_2),eye(2^(M(k_2)-1))),[M(k_2-1)+1,M(k_2-1)+j_2],2*ones(1,M(k_2-1)+M(k_2))); 131 | rho_right{k_2} = V'*rho_right{k_2}*V; 132 | end 133 | end 134 | end 135 | 136 | %Generating left hand side of commutator for M_j^k. Note that we can use application 137 | %of all unitaries before the _j^k Neuron 138 | V = Swap(kron(U{k}(:,:,j),eye(2^(M(k)-1))),[M(k-1)+1,M(k-1)+j],2*ones(1,M(k-1)+M(k))); 139 | rho_left = V*rho_left*V'; 140 | 141 | rho_right{k} = V*rho_right{k}*V'; 142 | 143 | M_Update = Comm(rho_left,rho_right{k}); 144 | 145 | Kxkj = PartialTrace(M_Update, [M(k-1)+1:M(k-1)+j-1,M(k-1)+j+1:M(k-1)+M(k)], 2*ones(1,M(k-1)+M(k))); 146 | 147 | if isfield(varargin, 'sparse') 148 | sparsity = varargin.('sparse'); 149 | sparsity = cellfun(@(c) logical(c), sparsity, 'UniformOutput', false); % convert sparsity to logical 150 | NumBonds = M(k-1); % number of connections if fully connected 151 | bonds = 1:NumBonds; 152 | cut = bonds(~sparsity{k-1}(j,:)); % indices of connections to cut 153 | NumCut = length(cut); % number of connections to cut 154 | if NumCut > 0 155 | NumQbits = NumBonds + NumCut + 1; 156 | % parameter matrix for fully connected case 157 | % tensored with identities on NumCut qubits: 158 | K_sparse = kron(Kxkj, eye(2^NumCut)); 159 | for i = 1:NumCut % swap identities to disconnected qubits 160 | K_sparse = Swap(K_sparse, [cut(i), NumQbits+1-i], 2*ones(1, NumQbits)); 161 | end 162 | % partial trace over swapped disconnected qubits: 163 | Kxkj = PartialTrace(K_sparse, NumQbits+1-(1:NumCut), 2*ones(1, NumQbits)); 164 | end 165 | end 166 | K{k}(:,:,j) = K{k}(:,:,j) + Kxkj; 167 | end 168 | end 169 | end 170 | 171 | %Updating all Unitaries in the Network 172 | momentum = 0; %Initialization of momentum term. 173 | 174 | for k = 2:N_NumLay 175 | % if ((if_RMSprop || momentum_coefficient || if_Adam || if_Nadam) && (round == 2)) 176 | % PrevK{k}=K{k}; 177 | % if (if_RMSprop || if_Adam || if_Nadam) 178 | % RenormL{k} = zeros(M(k)); 179 | % end 180 | % end 181 | for j = 1:M(k) 182 | K{k}(:,:,j) = (2^M(k-1))*K{k}(:,:,j); 183 | %UpdateMatrix{k}(:,:,j) = K{k}(:,:,j); 184 | if momentum_coefficient 185 | momentum = momentum_coefficient*PrevK{k}(:,:,j); %Momentum term. 186 | if (if_Adam || if_Nadam) 187 | momentum = momentum +(1 - momentum_coefficient)*K{k}(:,:,j); 188 | PrevK{k}(:,:,j) = momentum; 189 | momentum = momentum /(1 - momentum_coefficient^round); 190 | else 191 | %PrevK{k}(:,:,j) = momentum + K{k}(:,:,j); 192 | end 193 | end 194 | if (if_RMSprop || if_Adam || if_Nadam) 195 | RenormL{k}(j) = RMSprop_coefficient*RenormL{k}(j)+... 196 | (1-RMSprop_coefficient)*SpectralRange(K{k}(:,:,j)^2); 197 | if if_RMSprop 198 | %UpdateMatrix{k}(:,:,j) = K{k}(:,:,j)/sqrt(RenormL{k}(j) + min([eps, 1])^16) + momentum; 199 | momentum = K{k}(:,:,j)/sqrt(RenormL{k}(j) + min([eps, 1])^16) + momentum; 200 | PrevK{k}(:,:,j) = momentum; 201 | %RMSprop algorithm for learning rate renormalization 202 | else 203 | %RenormL{k}(j) = RenormL{k}(j)/(1 - RMSprop_coefficient^round); 204 | if if_Nadam 205 | momentum = momentum_coefficient* momentum + ... 206 | ((1-momentum_coefficient)/(1-momentum_coefficient^round))* K{k}(:,:,j); 207 | end 208 | %UpdateMatrix{k}(:,:,j) = momentum /(sqrt(RenormL{k}(j)) + min([eps, 1])^8); 209 | momentum = momentum /... 210 | (sqrt(RenormL{k}(j)/(1 - RMSprop_coefficient^round)) + min([eps, 1])^8); 211 | end 212 | else 213 | %UpdateMatrix{k}(:,:,j) = K{k}(:,:,j) + momentum; 214 | %fprintf('M=%1.5f',momentum_coefficient); 215 | if momentum_coefficient 216 | momentum = K{k}(:,:,j) + momentum; 217 | else 218 | momentum = K{k}(:,:,j); 219 | end 220 | end 221 | %U{k}(:,:,j) =expm((-eps*2^M(k-1)/(N_NumTrain*lambda))*K{k}(:,:,j))*U{k}(:,:,j); 222 | %U{k}(:,:,j) =expm((-eps/(lambda*N_NumTrain))*UpdateMatrix{k}(:,:,j))*U{k}(:,:,j); 223 | U{k}(:,:,j) =expm((-eps/(lambda*N_NumTrain))*momentum)*U{k}(:,:,j); 224 | end 225 | end 226 | 227 | %Save the cost function of this round 228 | c = CostNetwork(phi_in,phi_out,U,M); 229 | CList(round) = c; 230 | disp(c) 231 | 232 | end 233 | 234 | end 235 | -------------------------------------------------------------------------------- /Autoencoder-MATLAB/UnitaryNoise.m: -------------------------------------------------------------------------------- 1 | function psi_noisy = UnitaryNoise(psi, n, t, q) 2 | % SpinFlipNoise applies n times spin-flip noise to a state psi 3 | % with noise parameter t and number of noisy gates q. 4 | % 5 | % in: 6 | % psi: noiseless state. 7 | % n: number of noise realizations. 8 | % t: noise strength, "time" during which noise acts, around t=1 the noise is 9 | % so strong the distribution is essentially uniform. 10 | % q: number of noisy gates, controls how good of an approximation to 11 | % Brownian the noise is. 12 | % out: 13 | % psi_noisy: psi_noisy(:,i) is the ith realization of a noisy psi. 14 | 15 | dim = length(psi); % dimension of Hilbert space 16 | psi_noisy = zeros(dim, n); 17 | for i = 1:n 18 | psi_noisy(:,i) = RandomUnitary1(dim,t,q)*psi; 19 | end -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/ApplyLayer.m: -------------------------------------------------------------------------------- 1 | %Application of all unitaries in one given layer. This corresponds to the 2 | %action of the \mathcal{E} on a given start density matrix rho_in. 3 | function rho_out = ApplyLayer(rho_in,U,N_CorrLay,N_PrevLay) 4 | 5 | %pho_in (pho_out): input (output) state of the corresponding layer 6 | %N_CorrLay (N_PrevLay): Number of neurons in the corresponding (previous) Layer 7 | %U array containing all N_CorrLay Unitaries of the corresponding Layer 8 | 9 | 10 | %Initialising Input State on all N_CorrLay + N_PrevLay Qubits 11 | RHO_in_whole = kron(rho_in,[1;zeros(2^N_CorrLay -1,1)]*[1;zeros(2^N_CorrLay -1,1)]'); 12 | 13 | %Calculating Output on all N_CorrLay + N_PrevLay Qubits 14 | RHO_out_whole = RHO_in_whole; 15 | for j= 1:N_CorrLay 16 | V = Swap(kron(U(:,:,j),eye(2^(N_CorrLay - 1))),[N_PrevLay+1,N_PrevLay+j],2*ones(1,N_CorrLay+N_PrevLay)); 17 | RHO_out_whole = V*RHO_out_whole*V'; 18 | end 19 | 20 | %Calculating Output state of the Neurons in the corresponding Layer 21 | rho_out = PartialTrace(RHO_out_whole,1:N_PrevLay,2*ones(1,N_CorrLay+N_PrevLay)); 22 | 23 | 24 | 25 | end 26 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/ApplyNetwork.m: -------------------------------------------------------------------------------- 1 | %Calculates the output state/density matrix for som given input vector 2 | %phi_in 3 | function rho_out = ApplyNetwork(phi_in,U,M) 4 | 5 | % M array of Number of Neurons in each layer, i.e. size(M,2) = Num_Layers, M(1,j) = Num_Neurons in Layer j 6 | 7 | 8 | N_Layers = size(M,2); 9 | 10 | rho_out = phi_in*phi_in'; 11 | 12 | for k = 2:N_Layers 13 | rho_out = ApplyLayer(rho_out,U{k},M(k),M(k-1)); 14 | end 15 | 16 | 17 | end 18 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/AutoData.m: -------------------------------------------------------------------------------- 1 | 2 | function [phi_in, phi_out, test_in, test_out] = AutoData(mode, n, m) 3 | dim = 2^m; 4 | if mode == 1 5 | p = 0.4; 6 | n0 = round(p*n); 7 | phi0 = ghz(m, 0); 8 | flip0 = [0, 1; 1, 0]; 9 | id = eye(2); 10 | flip = zeros(dim,dim,n); 11 | phi = zeros(dim,n); 12 | for i = 1:m 13 | f = flip0; 14 | for j = 1:(i-1) 15 | f = kron(id, f); 16 | end 17 | for j = (i+1):m 18 | f = kron(f, id); 19 | end 20 | flip(:,:,i) = f; 21 | phi(:,i) = f*phi0; 22 | end 23 | % phi_rand = phi(:,randi(m,1,3*n)); 24 | % phi_in = phi_rand(:,1:n); 25 | % phi_out = phi_rand(:,n+1:2*n); 26 | % test_in = phi_rand(:,2*n+1:end); 27 | phi_rand = phi(:,randi(m,1,3*n0)); 28 | rep_phi0 = repmat(phi0, 1, n-n0); 29 | phi_in = cat(2, phi_rand(:,1:n0), rep_phi0); 30 | phi_in = phi_in(:,randi(n,1,n)); 31 | phi_out = cat(2, phi_rand(:,n0+1:2*n0), rep_phi0); 32 | phi_out = phi_out(:,randi(n,1,n)); 33 | test_in = cat(2, phi_rand(:,2*n0+1:end), rep_phi0); 34 | test_out = repmat(phi0, 1, n); 35 | end 36 | if mode == 2 37 | ghz_plus = ghz(m,0); 38 | ghz_minus = ghz(m,pi); 39 | phi_plus = repmat(ghz_plus, 1, floor(n/2)); 40 | phi_minus = repmat(ghz_minus, 1, ceil(n/2)); 41 | phi_in = cat(2, phi_plus, phi_minus); 42 | phi_out = phi_in; 43 | test_in = cat(2, ghz_plus, ghz_minus); 44 | test_out = test_in; 45 | end 46 | if mode == 3 47 | sgm = 0.5; 48 | phi_rand = repmat(exp(1i*normrnd(0, sgm, [1,3*n])),dim,1).*ghz(m,normrnd(0, sgm, [1,3*n])); 49 | phi_in = phi_rand(:,1:n); 50 | phi_out = phi_rand(:,n+1:2*n); 51 | test_in = phi_rand(:,2*n+1:end); 52 | test_out = repmat(ghz(m,0), 1, n); 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/AutoEncoder.m: -------------------------------------------------------------------------------- 1 | 2 | m = 3; 3 | M = [m,1,m]; 4 | n = 50; 5 | iter = 70; 6 | mode = 3; 7 | lambda = 0.8; %0.5 8 | dim = 2^m; 9 | if mode == 1 10 | path = 'Flip'; 11 | elseif mode == 3 12 | path = 'Rot'; 13 | end 14 | 15 | U = QuickInitilizer(M); 16 | tic 17 | [in, out, tin, tout] = AutoData(mode, n, m); 18 | [U, CList] = TrainNetwork(in, out, U, M, lambda, iter); 19 | toc 20 | 21 | C = CostNetwork(tin, tout, U, M); 22 | disp(C) 23 | 24 | plot(CList) 25 | 26 | datafid = fidelity1(tin, tout); 27 | netout = zeros(dim, dim, n); 28 | for i = 1:n 29 | netout(:,:,i) = ApplyNetwork(tin(:,i), U, M); 30 | end 31 | netfid = fidelity2(netout, tout); 32 | 33 | figure 34 | hold 35 | plot(1:n, datafid, 'rd', 'LineWidth', 2) 36 | plot(1:n, netfid, 'b+', 'LineWidth', 2) 37 | xlabel('Sample') 38 | ylabel('GHZ Fidelity') 39 | saveas(gcf, strcat(path, '_Fid.png')) 40 | 41 | figure 42 | plot(1:iter, CList, 'LineWidth', 2) 43 | xlabel('Iteration') 44 | ylabel('Cost') 45 | saveas(gcf, strcat(path, '_Cost.png')) 46 | 47 | function flist = fidelity1(in, out) % vectors 48 | flist = abs(dot(out, in, 1)).^2; 49 | end 50 | 51 | function flist = fidelity2(in, out) % in: density matrices, out: vectors 52 | n = length(out); 53 | flist = zeros(n,1); 54 | for i = 1:n 55 | flist(i) = real(dot(out(:,i), in(:,:,i)*out(:,i))); 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/AverageGeneralization.m: -------------------------------------------------------------------------------- 1 | %This function averages over 20 rounds of the Generalization task 2 | function [z_3,z_ave] = AverageGeneralization 3 | z_3 = zeros(20,8); 4 | z_ave = zeros(1,8); 5 | 6 | %Specify the right M here 7 | M =[3,3]; 8 | 9 | for j =1:20 10 | 11 | %Specify how the traingsdata should be chosen here 12 | [phi_in,phi_out] = RandomUnitaryTrainingsData(10,8); 13 | 14 | U = QuickInitilizer(M); 15 | 16 | z_3(j,:) = GeneralizationTask(phi_in,phi_out,U,M); 17 | z_ave = z_ave + z_3(j,:); 18 | end 19 | z_ave = z_ave/20; 20 | 21 | end 22 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/BrownianCircuit.m: -------------------------------------------------------------------------------- 1 | function U = BrownianCircuit(dim,n,dt) 2 | %BrownianCircuit(dim,n,var,dt) creates a random unitary matrix by multiplying 3 | % exp(i H_1 dt) exp(i H_2 dt) ... exp(i H_n dt) 4 | %for random normal distributed hermitian dim-dimensional matricies \{ H_i \}_{i=1}^{n} with variance 1. 5 | 6 | U = eye(dim); 7 | 8 | for j= 1:n 9 | Re = randn(dim); 10 | Im = 1i*randn(dim); 11 | C = Re + Im; 12 | H = (C + C')/4; 13 | U = U*expm(1i*H*dt); 14 | end 15 | end 16 | 17 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/Comm.m: -------------------------------------------------------------------------------- 1 | %Calculates Commutator of matrix A and B 2 | function C = Comm(A,B) 3 | 4 | C = A*B -B*A; 5 | 6 | end 7 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/CostNetwork.m: -------------------------------------------------------------------------------- 1 | %Calculates Cost function of Network given a set of input and target output 2 | %states 3 | function C = CostNetwork(phi_in,phi_out,U,M) 4 | 5 | %phi_in (phi_out): array with columns being the input (output) vectors 6 | N_NumTrain = size(phi_in,2); 7 | C = 0; 8 | 9 | for x=1:N_NumTrain 10 | C = C + dot(phi_out(:,x),ApplyNetwork(phi_in(:,x),U,M)*phi_out(:,x)); 11 | end 12 | 13 | C = real(C/N_NumTrain); 14 | 15 | end 16 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/DenoiseSpinFlips_Plot.m: -------------------------------------------------------------------------------- 1 | 2 | mode = 'train'; % 'train' or 'test' 3 | example = 10; 4 | id_train = 14; 5 | id_test = 1; 6 | % examples 7 | % 1: [3,1,3] 8 | % 2: [3,3,3] 9 | % 3: [3,1,3,1,3] training [3,1,3] 10 | % 4: [3,1,3,1,3] 11 | % 5: [4,1,4] 12 | % 6: [4,2,4] 13 | % 7: [4,2,4] sparse 14 | % 8: [4,2,1,2,4] 15 | % 9: [4,2,1,2,4] sparse 16 | % 10: [4,1,4,1,4] training [4,1,4] 17 | % 11: [4,1,4,1,4] 18 | % 12: [5,1,5] 19 | % 13: [5,3,5] 20 | % 14: [5,3,5] sparse 21 | % 15: [5,3,1,3,5] 22 | % 16: [5,3,1,3,5] sparse 23 | % 17: [5,1,5,1,5] training [5,1,5] 24 | % 18: [5,1,5,1,5] 25 | % 19: [3,1,3] denoising GHZ + and - 26 | % 20: [3,1,3] denoising GHZ with random phase 27 | % 21: [3,1,3,1,3] denoising GHZ with random phase, training [3,1,3] 28 | % 22: [3,2,1,3] denoising GHZ with random phase 29 | % 23: [3,2,1,2,3] denoising GHZ with random phase 30 | % 24: [3,2,3] denoising GHZ with random phase 31 | % 25: [3,2,2,1,3,1,3] denoising GHZ with random phase 32 | % 26: [3,2,2,2,3] denoising GHZ with random phase 33 | % 27: [3,4,2,1,3] denoising GHZ with random phase 34 | 35 | switch mode 36 | case 'train' 37 | switch example 38 | case {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28} 39 | savename = strcat('dsf_train_ex', num2str(example), '_train', num2str(id_train)); 40 | 41 | % load from example_train (title) 42 | load(strcat('Dat/', savename, '.mat'), 'pnum') 43 | % title = strcat('n=', num2str(n1), ', l=', num2str(lambda)); 44 | 45 | % load from example_train_p, legend 46 | cost = cell(1,pnum); 47 | legend = cell(1,pnum); 48 | for i = 1:pnum 49 | load(strcat('Dat/', savename, '_p', num2str(i), '.mat'), 'p', 'CList') 50 | cost{i} = CList; 51 | legend{i} = strcat('p=', num2str(p)); 52 | end 53 | 54 | % plot 55 | % PlotCost(cost, 'savename', savename, 'legend', legend, 'title', title) 56 | PlotCost(cost, 'savename', savename, 'legend', legend) 57 | 58 | % save 59 | % save(strcat('Dat/plot_', savename), 'cost', 'legend', 'title') 60 | save(strcat('Dat/plot_', savename), 'cost', 'legend') 61 | case 29 62 | savename = strcat('dsf_train_ex', num2str(example), '_train', num2str(id_train)); 63 | 64 | % load from example_train 65 | load(strcat('Dat/', savename, '.mat'), 'p', 'CList') 66 | cost = CList; 67 | legend = strcat('p=', num2str(p)); 68 | 69 | % plot 70 | % PlotCost(cost, 'savename', savename, 'legend', legend, 'title', title) 71 | PlotCost(cost, 'savename', savename, 'legend', legend) 72 | 73 | % save 74 | % save(strcat('Dat/plot_', savename), 'cost', 'legend', 'title') 75 | save(strcat('Dat/plot_', savename), 'cost', 'legend') 76 | otherwise 77 | error('Choose an example from 1 to 27.') 78 | end 79 | 80 | case 'test' 81 | switch example 82 | case {1, 2, 3, 4, 19, 21, 22, 23, 24, 25, 26, 27, 28} 83 | m = 3; 84 | 85 | savename = strcat('dsf_test_ex', num2str(example), '_train',... 86 | num2str(id_train), '_test', num2str(id_test)); 87 | 88 | % load from example_train_test 89 | load(strcat('Dat/', savename, '.mat'), 'n2', 'pnum') 90 | 91 | % load from example_train_test_p 92 | noise = zeros(1,pnum); 93 | mfid_in = zeros(1,pnum); 94 | mfid_out = zeros(1,pnum); 95 | sdv_out = zeros(1,pnum); 96 | for i = 1:pnum 97 | load(strcat('Dat/', savename, '_p', num2str(i), '.mat'),... 98 | 'p', 'meanfid_in', 'meanfid_out', 'varfid_out') 99 | noise(i) = p; 100 | mfid_in(i) = meanfid_in; 101 | mfid_out(i) = meanfid_out; 102 | sdv_out(i) = sqrt(varfid_out); 103 | end 104 | 105 | % analytics 106 | % [mfid_genin, varfid_genin, learnexpect] = FlipAnalyticsGHZ(3, noise); 107 | [mfid_genin, varfid_genin] = FlipAnalyticsGHZ(m, noise); 108 | sdv_genin = sqrt(varfid_genin / n2); 109 | % divide genin into two data sets according to learnexpect: 110 | % learnexpect = double(learnexpect); 111 | % mask1 = learnexpect; 112 | % mask1(mask1 == 0) = NaN; 113 | % mask2 = 1 - learnexpect; 114 | % mask2(mask2 == 0) = NaN; 115 | % mfid_genin1 = mfid_genin .* mask1; 116 | % mfid_genin2 = mfid_genin .* mask2; 117 | % sdv_genin1 = sdv_genin .* mask1; 118 | % sdv_genin2 = sdv_genin .* mask2; 119 | 120 | % summarize 121 | % fid = {mfid_genin1, mfid_genin2, mfid_in, mfid_out}; 122 | % sdv = {sdv_genin1, sdv_genin2, NaN * zeros(1,pnum), sdv_out}; 123 | % legend = ["gen. in 1", "gen. in 2", "noisy", "denoised"]; 124 | fid = {mfid_genin, mfid_in, mfid_out}; 125 | sdv = {sdv_genin, NaN * zeros(1,pnum), sdv_out}; 126 | % legend = ["gen. in", "noisy", "denoised"]; 127 | legend = ["expected noise", "noisy sample", "[3,1,3] denoised"]; 128 | 129 | % plot 130 | PlotDenoisingVsNoise(noise, fid,... 131 | 'sdv_fidelity', sdv, 'savename', savename, 'legend', legend,... 132 | 'xlabel', 'spin-flip probability p', 'ylabel', 'fidelity with GHZ-0/GHZ-$\pi$',... 133 | 'plotstyle', {{"+",'MarkerSize', 5, 'LineWidth', 1.5,'CapSize',0},... 134 | {".", 'MarkerSize', 25, 'LineWidth', 1.5},... 135 | {"o", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 20}}) 136 | 137 | % save 138 | save(strcat('Dat/plot_', savename), 'noise', 'fid', 'sdv', 'legend') 139 | case 20 140 | m = 3; 141 | 142 | savename = strcat('dsf_test_ex', num2str(example), '_train',... 143 | num2str(id_train), '_test', num2str(id_test)); 144 | 145 | % load from example_train_test 146 | load(strcat('Dat/', savename, '.mat'), 'n2', 'pnum') 147 | 148 | % load from example_train_test_p 149 | noise = zeros(1,pnum); 150 | mfid_in = zeros(1,pnum); 151 | mfid_inf = zeros(1,pnum); 152 | mfid_out = zeros(1,pnum); 153 | mfid_outf = zeros(1,pnum); 154 | sdv_out = zeros(1,pnum); 155 | sdv_outf = zeros(1,pnum); 156 | for i = 1:pnum 157 | load(strcat('Dat/', savename, '_p', num2str(i), '.mat'),... 158 | 'p', 'meanfid_in', 'meanfid_inf',... 159 | 'meanfid_out', 'meanfid_outf', 'varfid_out', 'varfid_outf') 160 | noise(i) = p; 161 | mfid_in(i) = meanfid_in; 162 | mfid_inf(i) = meanfid_inf; 163 | mfid_out(i) = meanfid_out; 164 | sdv_out(i) = sqrt(varfid_out); 165 | mfid_outf(i) = meanfid_outf; 166 | sdv_outf(i) = sqrt(varfid_outf); 167 | end 168 | 169 | % analytics 170 | % [mfid_genin, varfid_genin, learnexpect] = FlipAnalyticsGHZ(3, noise); 171 | 172 | % [mfid_genin, varfid_genin] = FlipAnalyticsGHZ(m, noise); 173 | % sdv_genin = sqrt(varfid_genin / n2); 174 | 175 | % divide genin into two data sets according to learnexpect: 176 | % learnexpect = double(learnexpect); 177 | % mask1 = learnexpect; 178 | % mask1(mask1 == 0) = NaN; 179 | % mask2 = 1 - learnexpect; 180 | % mask2(mask2 == 0) = NaN; 181 | % mfid_genin1 = mfid_genin .* mask1; 182 | % mfid_genin2 = mfid_genin .* mask2; 183 | % sdv_genin1 = sdv_genin .* mask1; 184 | % sdv_genin2 = sdv_genin .* mask2; 185 | 186 | % summarize 187 | % fid = {mfid_genin1, mfid_genin2, mfid_in, mfid_out}; 188 | % sdv = {sdv_genin1, sdv_genin2, NaN * zeros(1,pnum), sdv_out}; 189 | % legend = ["gen. in 1", "gen. in 2", "noisy", "denoised"]; 190 | fid = {mfid_in, mfid_inf, mfid_out, mfid_outf}; 191 | sdv = {NaN * zeros(1,pnum), NaN * zeros(1,pnum), sdv_out, sdv_outf}; 192 | % legend = ["gen. in", "noisy", "denoised"]; 193 | legend = ["noisy", "noisy, max. 1 flip", "[3,1,3] denoised", "[3,1,3] denoised, \newlinemax. 1 flip"]; 194 | 195 | % plot 196 | PlotDenoisingVsNoise(noise, fid,... 197 | 'sdv_fidelity', sdv, 'savename', savename, 'legend', legend,... 198 | 'xlabel', 'spin-flip probability p', 'ylabel', 'fidelity with GHZ-$\phi$',... 199 | 'plotstyle', {{".",'MarkerSize', 25, 'LineWidth', 1.5, 'Color', [0.85,0.325,0.098]},... 200 | {"s", 'MarkerSize', 7, 'LineWidth', 1.5, 'MarkerFaceColor', [0, 0.447, 0.741]},... 201 | {"o", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 20, 'Color', [0.929,0.694,0.125]},... 202 | {"x", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 15, 'Color', [0.494,0.184,0.556]}})%,... 203 | %'lposition', [0.36,0.21]) 204 | 205 | % save 206 | save(strcat('Dat/plot_', savename), 'noise', 'fid', 'sdv', 'legend') 207 | case {5, 6, 7, 8, 9, 10, 11} 208 | m = 4; 209 | 210 | savename = strcat('dsf_test_ex', num2str(example), '_train',... 211 | num2str(id_train), '_test', num2str(id_test)); 212 | 213 | % load from example_train_test 214 | load(strcat('Dat/', savename, '.mat'), 'n2', 'pnum') 215 | 216 | % load from example_train_test_p 217 | noise = zeros(1,pnum); 218 | mfid_in = zeros(1,pnum); 219 | mfid_out = zeros(1,pnum); 220 | sdv_out = zeros(1,pnum); 221 | for i = 1:pnum 222 | load(strcat('Dat/', savename, '_p', num2str(i), '.mat'),... 223 | 'p', 'meanfid_in', 'meanfid_out', 'varfid_out') 224 | noise(i) = p; 225 | mfid_in(i) = meanfid_in; 226 | mfid_out(i) = meanfid_out; 227 | sdv_out(i) = sqrt(varfid_out); 228 | end 229 | 230 | % analytics 231 | [mfid_genin, varfid_genin] = FlipAnalyticsGHZ(m, noise); 232 | sdv_genin = sqrt(varfid_genin / n2); 233 | 234 | % summarize 235 | fid = {mfid_genin, mfid_in, mfid_out}; 236 | sdv = {sdv_genin, NaN * zeros(1,pnum), sdv_out}; 237 | legend = ["gen. in", "noisy", "denoised"]; 238 | 239 | % plot 240 | PlotDenoisingVsNoise(noise, fid,... 241 | 'sdv_fidelity', sdv, 'savename', savename, 'legend', legend,... 242 | 'plotstyle', {{"+",'MarkerSize', 5, 'LineWidth', 1.5,'CapSize',0},... 243 | {".", 'MarkerSize', 25, 'LineWidth', 1.5},... 244 | {".", 'MarkerSize', 25, 'LineWidth', 1.5}}) 245 | 246 | % save 247 | save(strcat('Dat/plot_', savename), 'noise', 'fid', 'sdv', 'legend') 248 | case {12, 13, 14, 15, 16, 17, 18} 249 | m = 5; 250 | 251 | savename = strcat('dsf_test_ex', num2str(example), '_train',... 252 | num2str(id_train), '_test', num2str(id_test)); 253 | 254 | % load from example_train_test 255 | load(strcat('Dat/', savename, '.mat'), 'n2', 'pnum') 256 | 257 | % load from example_train_test_p 258 | noise = zeros(1,pnum); 259 | mfid_in = zeros(1,pnum); 260 | mfid_out = zeros(1,pnum); 261 | sdv_out = zeros(1,pnum); 262 | for i = 1:pnum 263 | load(strcat('Dat/', savename, '_p', num2str(i), '.mat'),... 264 | 'p', 'meanfid_in', 'meanfid_out', 'varfid_out') 265 | noise(i) = p; 266 | mfid_in(i) = meanfid_in; 267 | mfid_out(i) = meanfid_out; 268 | sdv_out(i) = sqrt(varfid_out); 269 | end 270 | 271 | % analytics 272 | [mfid_genin, varfid_genin] = FlipAnalyticsGHZ(m, noise); 273 | sdv_genin = sqrt(varfid_genin / n2); 274 | 275 | % summarize 276 | fid = {mfid_genin, mfid_in, mfid_out}; 277 | sdv = {sdv_genin, NaN * zeros(1,pnum), sdv_out}; 278 | legend = ["gen. in", "noisy", "denoised"]; 279 | 280 | % plot 281 | PlotDenoisingVsNoise(noise, fid,... 282 | 'sdv_fidelity', sdv, 'savename', savename, 'legend', legend) 283 | 284 | % save 285 | save(strcat('Dat/plot_', savename), 'noise', 'fid', 'sdv', 'legend') 286 | case 29 287 | m = 4; 288 | 289 | savename = strcat('dsf_test_ex', num2str(example), '_train',... 290 | num2str(id_train), '_test', num2str(id_test)); 291 | ylabel = 'fidelity with GHZ-0'; 292 | legend = {'noisy', '[4,2,1,2,4] denoised'}; 293 | lposition = [0.71, 0.7]; 294 | 295 | % load from example_train_test 296 | load(strcat('Dat/', savename, '.mat'), 'p', 'fid_in', 'fid_out') 297 | 298 | % plot 299 | PlotDenoising(fid_in, fid_out, 'savename', savename,... 300 | 'ylabel', ylabel, 'legend', legend, 'lposition', lposition) 301 | 302 | % save 303 | save(strcat('Dat/plot_', savename), 'fid_in', 'fid_out', 'ylabel', 'legend', 'lposition') 304 | otherwise 305 | error('Choose an example from 1 to 27.') 306 | end 307 | otherwise 308 | error('Valid modes are "train" and "test".') 309 | end 310 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/DenoiseUnitary_Plot.m: -------------------------------------------------------------------------------- 1 | 2 | mode = 'test'; % 'train' or 'test' 3 | example = 9; 4 | id_train = 1; 5 | id_test = 1; 6 | % examples 7 | % 1: [3,1,3] 8 | % 2: [3,3,3] 9 | % 3: [3,1,3,1,3] training [3,1,3] 10 | % 4: [3,1,3,1,3] 11 | % 5: [4,1,4] 12 | % 6: [4,2,4] 13 | % 7: [4,2,4] sparse 14 | % 8: [4,2,1,2,4] 15 | % 9: [4,2,1,2,4] sparse 16 | % 10: [4,1,4,1,4] training [4,1,4] 17 | % 11: [4,1,4,1,4] 18 | % 12: [5,1,5] 19 | % 13: [5,3,5] 20 | % 14: [5,3,5] sparse 21 | % 15: [5,3,1,3,5] 22 | % 16: [5,3,1,3,5] sparse 23 | % 17: [5,1,5,1,5] training [5,1,5] 24 | % 18: [5,1,5,1,5] 25 | % 19: [3,1,3] denoising GHZ + and - 26 | % 20: [3,1,3] denoising GHZ with random phase 27 | 28 | switch mode 29 | case 'train' 30 | switch example 31 | case {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} 32 | savename = strcat('du_train_ex', num2str(example), '_train', num2str(id_train)); 33 | 34 | % load from example_train (title) 35 | load(strcat('Dat/', savename, '.mat'), 'pnum') 36 | % title = strcat('n=', num2str(n1), ', l=', num2str(lambda)); 37 | 38 | % load from example_train_p, legend 39 | cost = cell(1,pnum); 40 | legend = cell(1,pnum); 41 | for i = 1:pnum 42 | load(strcat('Dat/', savename, '_p', num2str(i), '.mat'), 'p', 'CList') 43 | cost{i} = CList; 44 | legend{i} = strcat('p=', num2str(p)); 45 | end 46 | 47 | % plot 48 | % PlotCost(cost, 'savename', savename, 'legend', legend, 'title', title) 49 | PlotCost(cost, 'savename', savename, 'legend', legend) 50 | 51 | % save 52 | % save(strcat('Dat/plot_', savename), 'cost', 'legend', 'title') 53 | save(strcat('Dat/plot_', savename), 'cost', 'legend') 54 | otherwise 55 | error('Choose an example from 1 to 20.') 56 | end 57 | 58 | case 'test' 59 | switch example 60 | case {1, 2, 3, 4, 19, 20} 61 | m = 3; 62 | 63 | savename = strcat('du_test_ex', num2str(example), '_train',... 64 | num2str(id_train), '_test', num2str(id_test)); 65 | 66 | % load from example_train_test 67 | load(strcat('Dat/', savename, '.mat'), 'n2', 'pnum') 68 | 69 | % load from example_train_test_p 70 | noise = zeros(1,pnum); 71 | mfid_in = zeros(1,pnum); 72 | mfid_out = zeros(1,pnum); 73 | sdv_in = zeros(1,pnum); 74 | sdv_out = zeros(1,pnum); 75 | for i = 1:pnum 76 | load(strcat('Dat/', savename, '_p', num2str(i), '.mat'),... 77 | 'p', 'meanfid_in','varfid_in', 'meanfid_out', 'varfid_out') 78 | noise(i) = p; 79 | mfid_in(i) = meanfid_in; 80 | sdv_in(i) = sqrt(varfid_in); 81 | mfid_out(i) = meanfid_out; 82 | sdv_out(i) = sqrt(varfid_out); 83 | end 84 | 85 | % analytics 86 | % [mfid_genin, varfid_genin, learnexpect] = FlipAnalyticsGHZ(3, noise); 87 | % [mfid_genin, varfid_genin] = FlipAnalyticsGHZ(m, noise); 88 | % sdv_genin = sqrt(varfid_genin / n2); 89 | % divide genin into two data sets according to learnexpect: 90 | % learnexpect = double(learnexpect); 91 | % mask1 = learnexpect; 92 | % mask1(mask1 == 0) = NaN; 93 | % mask2 = 1 - learnexpect; 94 | % mask2(mask2 == 0) = NaN; 95 | % mfid_genin1 = mfid_genin .* mask1; 96 | % mfid_genin2 = mfid_genin .* mask2; 97 | % sdv_genin1 = sdv_genin .* mask1; 98 | % sdv_genin2 = sdv_genin .* mask2; 99 | 100 | % summarize 101 | % fid = {mfid_genin1, mfid_genin2, mfid_in, mfid_out}; 102 | % sdv = {sdv_genin1, sdv_genin2, NaN * zeros(1,pnum), sdv_out}; 103 | % legend = ["gen. in 1", "gen. in 2", "noisy", "denoised"]; 104 | % fid = {mfid_genin, mfid_in, mfid_out}; 105 | % sdv = {sdv_genin, NaN * zeros(1,pnum), sdv_out}; 106 | % legend = ["gen. in", "noisy", "denoised"]; 107 | 108 | fid = { mfid_in, mfid_out}; 109 | sdv = { sdv_in, sdv_out}; 110 | legend = ["noisy", "denoised"]; 111 | 112 | % plot 113 | PlotDenoisingVsNoise(noise, fid,... 114 | 'sdv_fidelity', sdv, 'savename', savename, 'legend', legend) 115 | 116 | % save 117 | save(strcat('Dat/plot_', savename), 'noise', 'fid', 'sdv', 'legend') 118 | case {5, 6, 7, 8, 9, 10, 11} 119 | m = 4; 120 | 121 | savename = strcat('du_test_ex', num2str(example), '_train',... 122 | num2str(id_train), '_test', num2str(id_test)); 123 | 124 | % load from example_train_test 125 | load(strcat('Dat/', savename, '.mat'), 'n2', 'pnum') 126 | 127 | % load from example_train_test_p 128 | noise = zeros(1,pnum); 129 | mfid_in = zeros(1,pnum); 130 | mfid_out = zeros(1,pnum); 131 | sdv_out = zeros(1,pnum); 132 | sdv_in = zeros(1,pnum); 133 | for i = 1:pnum 134 | load(strcat('Dat/', savename, '_p', num2str(i), '.mat'),... 135 | 'p', 'meanfid_in','varfid_in', 'meanfid_out', 'varfid_out') 136 | noise(i) = p; 137 | mfid_in(i) = meanfid_in; 138 | sdv_in(i) = sqrt(varfid_in); 139 | mfid_out(i) = meanfid_out; 140 | sdv_out(i) = sqrt(varfid_out); 141 | end 142 | 143 | % analytics 144 | %[mfid_genin, varfid_genin] = FlipAnalyticsGHZ(m, noise); 145 | %sdv_genin = sqrt(varfid_genin / n2); 146 | 147 | % summarize 148 | fid = {mfid_in, mfid_out}; 149 | sdv = {sdv_in, sdv_out}; 150 | legend = ["noisy", "denoised"]; 151 | 152 | % plot 153 | PlotDenoisingVsNoise(noise, fid,... 154 | 'sdv_fidelity', sdv, 'savename', savename, 'legend', legend) 155 | 156 | % save 157 | save(strcat('Dat/plot_', savename), 'noise', 'fid', 'sdv', 'legend') 158 | case {12, 13, 14, 15, 16, 17, 18} 159 | m = 5; 160 | 161 | savename = strcat('du_test_ex', num2str(example), '_train',... 162 | num2str(id_train), '_test', num2str(id_test)); 163 | 164 | % load from example_train_test 165 | load(strcat('Dat/', savename, '.mat'), 'n2', 'pnum') 166 | 167 | % load from example_train_test_p 168 | noise = zeros(1,pnum); 169 | mfid_in = zeros(1,pnum); 170 | mfid_out = zeros(1,pnum); 171 | sdv_out = zeros(1,pnum); 172 | for i = 1:pnum 173 | load(strcat('Dat/', savename, '_p', num2str(i), '.mat'),... 174 | 'p', 'meanfid_in', 'meanfid_out', 'varfid_out') 175 | noise(i) = p; 176 | mfid_in(i) = meanfid_in; 177 | mfid_out(i) = meanfid_out; 178 | sdv_out(i) = sqrt(varfid_out); 179 | end 180 | 181 | % analytics 182 | [mfid_genin, varfid_genin] = FlipAnalyticsGHZ(m, noise); 183 | sdv_genin = sqrt(varfid_genin / n2); 184 | 185 | % summarize 186 | fid = {mfid_genin, mfid_in, mfid_out}; 187 | sdv = {sdv_genin, NaN * zeros(1,pnum), sdv_out}; 188 | legend = ["gen. in", "noisy", "denoised"]; 189 | 190 | % plot 191 | PlotDenoisingVsNoise(noise, fid,... 192 | 'sdv_fidelity', sdv, 'savename', savename, 'legend', legend) 193 | 194 | % save 195 | save(strcat('Dat/plot_', savename), 'noise', 'fid', 'sdv', 'legend') 196 | otherwise 197 | error('Choose an example from 1 to 20.') 198 | end 199 | otherwise 200 | error('Valid modes are "train" and "test".') 201 | end 202 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/FChannel.m: -------------------------------------------------------------------------------- 1 | %Applicaton of F (conjugate) Channel 2 | function rho_result = FChannel(rho_start,U,N_StartLay,N_ResLay) 3 | 4 | %This function maps the start density matrix rho_start to the image under the F 5 | %channel, which is rho_result. 6 | 7 | %N_StartLay: Number of neurons in the starting layer where rho_start lives. 8 | %N_ResLay: Number of neurons in the resulting layer where rho_result lives. 9 | 10 | RHO_whole = kron(eye(2^N_ResLay),rho_start); 11 | 12 | for j = 1 : N_StartLay 13 | j_1 = N_StartLay - j +1; 14 | V = Swap(kron(U(:,:,j_1),eye(2^(N_StartLay - 1))),[N_ResLay+1,N_ResLay+j_1],2*ones(1,N_StartLay+N_ResLay)); 15 | RHO_whole = V'*RHO_whole*V; 16 | end 17 | RHO_whole = kron(eye(2^N_ResLay),[1;zeros(2^N_StartLay-1,1)]*[1;zeros(2^N_StartLay-1,1)]')*RHO_whole; 18 | rho_result = PartialTrace(RHO_whole,N_ResLay+1:N_ResLay+N_StartLay,2*ones(1,N_StartLay+N_ResLay)); 19 | end 20 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/Fidelity.m: -------------------------------------------------------------------------------- 1 | function flist = Fidelity(target, compare) 2 | % Fidelity computes the fidelity between pure target and 3 | % pure or mixed comparison states 4 | % 5 | % in: 6 | % target: target(:,i) is the ith pure target state of length > 1 7 | % compare: compare(:,i) is the ith pure state or 8 | % compare(:,:,i) is the ith density matrix 9 | % to be compared to the ith target state 10 | % out: 11 | % flist: array of fidelities 12 | 13 | st = size(target); 14 | sc = size(compare); 15 | n = st(end); % number of fidelities 16 | typec = length(sc); % determine if compare is mixed or pure 17 | if sc(end) ~= n 18 | if n == 1 && isequal(sc, [st(1), st(1)]) 19 | % ensure that a single density matrix is not interpreted as two vectors 20 | typec = 3; 21 | else 22 | error('The last dimensions of the input arguments have to match.') 23 | end 24 | end 25 | if typec == 2 % pure-pure state fidelity 26 | flist = abs(dot(compare, target)).^2; 27 | elseif typec == 3 % pure-mixed state fidelity 28 | flist = zeros(1,n); 29 | for i = 1:n 30 | flist(i) = real(dot(target(:,i), compare(:,:,i)*target(:,i))); 31 | end 32 | else 33 | error('Second input argument has wrong number of dimensions.') 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/FlipAnalyticsGHZ.m: -------------------------------------------------------------------------------- 1 | function [mean_fidelity, var_fidelity] = FlipAnalyticsGHZ(m, p) 2 | % FlipAnalyticsGHZ provides properties of spin-flip noise on GHZ states 3 | % 4 | % in: 5 | % m: number of qubits 6 | % p: spin-flip probability per qubit or array of spin-flip probabilities 7 | % out: 8 | % mean_fidelity: mean GHZ fidelity (for each p) 9 | % var_fidelity: variance of GHZ fidelity (for each p) 10 | 11 | mean_fidelity = p.^m + (1 - p).^m ; % probability of zero effective flips 12 | var_fidelity = mean_fidelity .* (1 - mean_fidelity); 13 | 14 | % denoising is expected if zero effective flips is most probable 15 | % this is true for all p < 1/2 16 | % for p = 1/2, any effective flipped state has the same probability 17 | end 18 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/GHZ.m: -------------------------------------------------------------------------------- 1 | function psi = GHZ(m, phi) 2 | % GHZ creates ghz states with relative phases 3 | % 4 | % in: 5 | % m: number of qubits 6 | % phi (optional, default = 0): array of relative phases 7 | % out: 8 | % psi: psi(:,j) is the state (up + exp(i*phi(j)) down) / sqrt(2) 9 | % in the tensor product basis 10 | 11 | if nargin < 2 12 | phi = 0; 13 | end 14 | 15 | psi = zeros(2^m, length(phi)); 16 | psi(1,:) = 1; 17 | psi(end,:) = exp(1i*phi); 18 | psi = psi / sqrt(2); 19 | end 20 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/GeneralizationTask.m: -------------------------------------------------------------------------------- 1 | %Computes all Cost functions in Generalization Task 2 | 3 | function CList = GeneralizationTask(phi_in,phi_out,U,M) 4 | 5 | dim = 2^M(1); 6 | %size(phi_in,2) = N_NumTrain can be bigger than dim 7 | 8 | CList= zeros(1,dim); 9 | for j = 1:dim 10 | phi_in_use = phi_in(:,1:j); 11 | phi_out_use = phi_out(:,1:j); 12 | 13 | %Specify good iteration number and lambda 14 | [x,z] = TrainNetwork(phi_in_use,phi_out_use,U,M,1.5,350); 15 | CList(j) = CostNetwork(phi_in,phi_out,x,M); 16 | end 17 | 18 | end 19 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/How to use this program.txt: -------------------------------------------------------------------------------- 1 | You will need the MATLAB Toolbox QETLAB ( see http://www.qetlab.com/Main_Page). The program uses its implementation of the PartialTrace and the Swap Operation. 2 | 3 | The program can implement general Network configurations. These configurations are stored in the M array. 4 | A Network with two layers with two Neurons each is given by M = [2,2]. 5 | A Network with three layers with two Neurons in the input and output layer and three Neurons in the hidden layer is given by M =[2,3,2]. 6 | 7 | First Initilize the Network by generating an array with random unitaries for a given network M with "QuickInitilizer.m". 8 | The unitaries are stored in the cell array U. U{k}(:,:,j) is then the corresponding unitary of the jth neuron in the kth layer. 9 | 10 | Then Train the Network with "TrainNetwork.m". 11 | 12 | You will need an array of traaining input and output states phi_in and phi_out, where phi_in(:,j) is the jth input vector of your training sample. 13 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/Noisydata.m: -------------------------------------------------------------------------------- 1 | %Calculates Costfunctions for Noisy data Plot. phi_in_start and 2 | %phi_out_start should be RandomUnitaryTrainingData 3 | 4 | function CList = Noisydata(phi_in_start,phi_out_start,U,M,s) 5 | %s is the number of steps between each point 6 | 7 | N_NumTrain = size(phi_in_start,2); 8 | 9 | dim = 2^M(1); 10 | 11 | 12 | N_iter = N_NumTrain/s; 13 | % N_iter should be integer 14 | 15 | 16 | CList = zeros(1,N_iter); 17 | phi_in = phi_in_start; 18 | phi_out = phi_out_start; 19 | [phi_in_noisy,phi_out_noisy] = Randomtrainingdata(N_NumTrain,dim); 20 | 21 | for j = 1:N_iter+1 22 | 23 | %Specify good iteration number and lambda 24 | x = TrainNetwork(phi_in,phi_out,U,M,1.5,250); 25 | CList(j) = CostNetwork(phi_in_start,phi_out_start,x,M); 26 | if j < N_iter+1 27 | List = randperm(N_NumTrain); 28 | phi_in = phi_in_start(:,List); 29 | phi_out = phi_out_start(:,List); 30 | 31 | List = randperm(N_NumTrain); 32 | phi_in_noisy = phi_in_noisy(:,List); 33 | phi_out_noisy = phi_out_noisy(:,List); 34 | 35 | phi_in(:,1:s*j) = phi_in_noisy(:,1:s*j); 36 | phi_out(:,1:s*j) = phi_out_noisy(:,1:s*j); 37 | end 38 | 39 | end 40 | 41 | 42 | 43 | end 44 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/Paperplot1.m: -------------------------------------------------------------------------------- 1 | 2 | savename1 = 'pp1_a'; 3 | load('Dat/plot_dsf_test_ex8_train1_test1', 'noise', 'fid', 'sdv') 4 | fid1 = fid; 5 | sdv1 = sdv; 6 | load('Dat/plot_dsf_test_ex10_train6_test1', 'fid', 'sdv') 7 | noise1 = noise; 8 | fid1 = cat(2, fid1, fid{end}); 9 | sdv1 = cat(2, sdv1, sdv{end}); 10 | legend1 = ["expected noise", "noisy sample", "[4,2,1,2,4] denoised", "[4,1,4,1,4] denoised"]; 11 | 12 | PlotDenoisingVsNoise(noise1, fid1,... 13 | 'sdv_fidelity', sdv1, 'savename', savename1, 'legend', legend1, 'lposition', [0.31,0.21],... 14 | 'xlabel', 'spin-flip probability p', 'ylabel', 'fidelity with GHZ-0',... 15 | 'plotstyle', {{"+",'MarkerSize', 5, 'LineWidth', 1.5, 'CapSize', 0},... 16 | {".", 'MarkerSize', 25, 'LineWidth', 1.5},... 17 | {"o", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 20},... 18 | {"x", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 15}}) 19 | 20 | savename2 = 'pp1_b'; 21 | load('Dat/plot_du_test_ex8_train1_test1', 'noise', 'fid', 'sdv') 22 | fid2 = fid; 23 | sdv2 = sdv; 24 | load('Dat/plot_du_test_ex10_train3_test1', 'fid', 'sdv') 25 | noise2 = noise; 26 | fid2 = cat(2, fid2, fid{end}); 27 | sdv2 = cat(2, sdv2, sdv{end}); 28 | legend2 = ["noisy", "[4,2,1,2,4] \newlinedenoised", "[4,1,4,1,4] \newlinedenoised"]; 29 | 30 | PlotDenoisingVsNoise(noise2, fid2,... 31 | 'sdv_fidelity', sdv2, 'savename', savename2, 'legend', legend2, 'lposition', [0.25,0.235],... 32 | 'xlabel', 'noise strength q', 'ylabel', 'fidelity with GHZ-0',... 33 | 'plotstyle', {{".", 'MarkerSize', 25, 'LineWidth', 1.5, 'Color', [0.85,0.325,0.098]},... 34 | {"o", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 20, 'Color', [0.929,0.694,0.125]},... 35 | {"x", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 15, 'Color', [0.494,0.184,0.556]}}) 36 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/Paperplot2.m: -------------------------------------------------------------------------------- 1 | 2 | savename1 = 'pp2_a'; 3 | load('Dat/plot_dsf_test_ex9_train2_test1', 'noise', 'fid', 'sdv') 4 | fid1 = fid; 5 | sdv1 = sdv; 6 | noise1 = noise; 7 | legend1 = ["expected noise", "noisy sample", "[4,2,1,2,4] sparse \newlinedenoised"]; 8 | 9 | PlotDenoisingVsNoise(noise1, fid1,... 10 | 'sdv_fidelity', sdv1, 'savename', savename1, 'legend', legend1, 'lposition', [0.28,0.21],... 11 | 'xlabel', 'spin-flip probability p', 'ylabel', 'fidelity with GHZ-0',... 12 | 'plotstyle', {{"+",'MarkerSize', 5, 'LineWidth', 1.5, 'CapSize', 0},... 13 | {".", 'MarkerSize', 25, 'LineWidth', 1.5},... 14 | {"o", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 20}}) 15 | 16 | savename2 = 'pp2_b'; 17 | load('Dat/plot_du_test_ex9_train1_test1', 'noise', 'fid', 'sdv') 18 | fid2 = fid; 19 | sdv2 = sdv; 20 | noise2 = noise; 21 | legend2 = ["noisy", "[4,2,1,2,4] sparse \newlinedenoised"]; 22 | 23 | PlotDenoisingVsNoise(noise2, fid2,... 24 | 'sdv_fidelity', sdv2, 'savename', savename2, 'legend', legend2, 'lposition', [0.28,0.19],... 25 | 'xlabel', 'noise strength q', 'ylabel', 'fidelity with GHZ-0',... 26 | 'plotstyle', {{".", 'MarkerSize', 25, 'LineWidth', 1.5, 'Color', [0.85,0.325,0.098]},... 27 | {"o", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 20, 'Color', [0.929,0.694,0.125]}}) 28 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/Paperplot4.m: -------------------------------------------------------------------------------- 1 | 2 | savename1 = 'pp4_b'; 3 | load('Dat/plot_dsf_test_ex10_train13_test1', 'noise', 'fid', 'sdv') 4 | fid1 = {fid{2}, fid{1}, fid{3}}; 5 | sdv1 = {sdv{2}, sdv{1}, sdv{3}}; 6 | noise1 = noise; 7 | legend1 = ["noisy sample", "expected noise", "[4,1,4,1,4] denoised"]; 8 | 9 | PlotDenoisingVsNoise(noise1, fid1,... 10 | 'sdv_fidelity', sdv1, 'savename', savename1, 'legend', legend1, 'lposition', [0.745,0.852],... 11 | 'xlabel', 'spin-flip probability p', 'ylabel', 'fidelity with GHZ-0',... 12 | 'plotstyle', {{".", 'MarkerSize', 25, 'LineWidth', 1.5, 'Color', [0.85,0.325,0.098]},... 13 | {"+",'MarkerSize', 5, 'LineWidth', 1.5, 'CapSize', 0, 'Color', [0, 0.447, 0.741]},... 14 | {"x", 'MarkerSize', 10, 'LineWidth', 1.5, 'CapSize', 15, 'Color', [0.494,0.184,0.556]}}) 15 | 16 | ax = gca; 17 | ax.XLim = [0.325, 0.49]; 18 | ax.XTick = [0.35, 0.4, 0.45]; 19 | savefig(strcat('Fig/dnvn_', savename1, '.fig')) 20 | saveas(gcf, strcat('Fig/dnvn_', savename1), 'png') 21 | saveas(gcf, strcat('Fig/dnvn_', savename1), 'epsc') 22 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/PlotCost.m: -------------------------------------------------------------------------------- 1 | function PlotCost(cost, varargin) 2 | % PlotCost plots cost arrays as a function of training round 3 | % 4 | % in: 5 | % cost: cost array or cell of cost arrays 6 | % optional in as name/value pairs (function(..., 'name', value, ...)): 7 | % savename: plots are saved at 'Fig/cost_savename'; default is no saving 8 | % legend: a cell of legend labels; 9 | % default: 1, 2,... if more than one data set is drawn 10 | % title: a plot title; default is no title 11 | 12 | if rem(length(varargin), 2) == 1 % test that optional input is paired 13 | error('Provide the optional input arguments as name/value pairs.') 14 | end 15 | varargin = cell2struct(varargin(2:2:end), varargin(1:2:end), 2); 16 | 17 | if ~iscell(cost) % for a single data set: ensure cost is a cell 18 | cost = {cost}; 19 | end 20 | num = length(cost); 21 | 22 | figure % plot 23 | hold on 24 | 25 | for i = 1:num 26 | plot(cost{i}, 'LineWidth', 2.5) 27 | end 28 | 29 | % set plot properties 30 | if isfield(varargin, 'legend') || num > 1 31 | if isfield(varargin, 'legend') 32 | leg = varargin.('legend'); 33 | else 34 | leg = string(1:num); 35 | end 36 | legend(leg, 'Location', 'eastoutside') 37 | end 38 | ax = gca; 39 | ax.YLim = [0, 1.1]; 40 | ax.LineWidth = 1.5; 41 | ax.FontSize = 16; % ticks; if not explicitly set: labels, legend 42 | xlabel('iteration') 43 | ylabel('fidelity') 44 | if isfield(varargin, 'title') 45 | title(varargin.('title'), 'FontWeight', 'normal') 46 | end 47 | hold off 48 | 49 | if isfield(varargin, 'savename') % save 50 | savename = varargin.('savename'); 51 | savefig(strcat('Fig/cost_', savename, '.fig')) 52 | saveas(gcf, strcat('Fig/cost_', savename), 'png') 53 | saveas(gcf, strcat('Fig/cost_', savename), 'epsc') 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/PlotDenoising.m: -------------------------------------------------------------------------------- 1 | function PlotDenoising(fidelity_in, fidelity_out, varargin) 2 | % PlotDenoising plots the ideal state fidelity of noisy and denoised states 3 | % 4 | % in: 5 | % fidelity_in: array of noisy state fidelities 6 | % fidelity_out: array of denoised state fidelities 7 | % optional in as name/value pairs (function(..., 'name', value, ...)): 8 | % savename: plots are saved at 'Fig/dn_savename'; default is no saving 9 | % title: a plot title; default is no title 10 | % ylabel: label string; default is 'fidelity' 11 | % legend: a cell of legend labels; 12 | % default: {'noisy', 'denoised'} 13 | % lposition: [left, bottom] array for legend positioning; 14 | % default is 'best' 15 | 16 | if rem(length(varargin), 2) == 1 % test that optional input is paired 17 | error('Provide the optional input arguments as name/value pairs.') 18 | end 19 | varargin = cell2struct(varargin(2:2:end), varargin(1:2:end), 2); 20 | 21 | figure % plot 22 | hold on 23 | 24 | plot(fidelity_in, "o", 'MarkerSize', 4, 'LineWidth', 1.5, 'Color', [0.85,0.325,0.098], 'MarkerFaceColor', [0.85,0.325,0.098]) 25 | plot(fidelity_out, "o", 'MarkerSize', 4, 'LineWidth', 1.5, 'Color', [0.929,0.694,0.125]) 26 | 27 | % set plot properties 28 | if isfield(varargin, 'legend') 29 | label = varargin.('legend'); 30 | else 31 | label = {'noisy', 'denoised'}; 32 | end 33 | if isfield(varargin, 'lposition') 34 | pos = {'Position', cat(2, varargin.('lposition'), [0,0])}; 35 | else 36 | pos = {}; 37 | end 38 | legend(label{:}, 'Orientation', 'horizontal', 'NumColumns', 1,... 39 | 'Location', 'best', pos{:}) 40 | ax = gca; 41 | ax.YLim = [0, 1.1]; 42 | ax.LineWidth = 1.5; 43 | ax.FontSize = 12; % ticks; if not explicitly set: labels, legend, title 44 | xlabel('test no') 45 | if isfield(varargin, 'ylabel') 46 | ylabel(varargin.('ylabel')) 47 | else 48 | ylabel('fidelity') 49 | end 50 | if isfield(varargin, 'title') 51 | title(varargin.('title'), 'FontWeight', 'normal') 52 | end 53 | hold off 54 | 55 | if isfield(varargin, 'savename') % save 56 | savename = varargin.('savename'); 57 | savefig(strcat('Fig/dn_', savename, '.fig')) 58 | saveas(gcf, strcat('Fig/dn_', savename), 'png') 59 | saveas(gcf, strcat('Fig/dn_', savename), 'epsc') 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/PlotDenoisingVsNoise.m: -------------------------------------------------------------------------------- 1 | function PlotDenoisingVsNoise(noise, mean_fidelity, varargin) 2 | % PlotDenoisingVsNoise plots mean fidelities as a function of noise strength 3 | % 4 | % in: 5 | % noise: an array of noise strengths or a cell of noise strength arrays 6 | % mean_fidelity: corr. array of mean fidelities or a cell of arrays; 7 | % if all cell elements correspond to one noise array, 8 | % noise can be provided as one array 9 | % optional in as name/value pairs (function(..., 'name', value, ...)): 10 | % sdv_fidelity: an array or cell of fidelity standard deviations 11 | % savename: plots are saved at 'Fig/dnvn_savename'; default is no saving 12 | % legend: a cell of legend labels; 13 | % default: 1, 2,... if more than one data set is drawn 14 | % plotstyle: a cell of plot styles as input to the errorbar function; 15 | % combine more than one prescription per plot style into a cell; 16 | % if only one data set is plotted, plotstyle can also be 17 | % a string or a cell directly containing several prescriptions; 18 | % default: {".", 'MarkerSize', 25, 'LineWidth', 1.5} 19 | % xlabel: label string; default is 'noise strength' 20 | % lposition: [left, bottom] array for legend positioning; 21 | % default is 'southwest' 22 | 23 | if rem(length(varargin), 2) == 1 % test that optional input is paired 24 | error('Provide the optional input arguments as name/value pairs.') 25 | end 26 | varargin = cell2struct(varargin(2:2:end), varargin(1:2:end), 2); 27 | 28 | if ~iscell(mean_fidelity) % for a single data set: ensure mean_fidelity is a cell 29 | mean_fidelity = {mean_fidelity}; 30 | end 31 | num = length(mean_fidelity); 32 | 33 | if isfield(varargin, 'sdv_fidelity') % define error bars 34 | err = varargin.('sdv_fidelity'); 35 | if ~iscell(err) % for a single data set: ensure err is a cell 36 | err = {err}; 37 | end 38 | else 39 | err = cellfun(@(x) NaN*x, mean_fidelity, 'UniformOutput', 0); 40 | end 41 | if isfield(varargin, 'plotstyle') % define plot styles 42 | plotstyle = varargin.('plotstyle'); 43 | if num == 1 % flexible input parsing for single data set 44 | if iscell(plotstyle) 45 | if ~iscell(plotstyle{1}) 46 | plotstyle = {plotstyle}; 47 | end 48 | else 49 | plotstyle = {{plotstyle}}; 50 | end 51 | else 52 | if iscell(plotstyle) 53 | for i = 1:num % flexible input parsing for multiple data sets 54 | istyle = plotstyle{i}; 55 | if ~iscell(istyle) 56 | plotstyle{i} = {istyle}; 57 | end 58 | end 59 | else 60 | error('The plotstyle has to be a cell of styles for each data set.') 61 | end 62 | end 63 | else 64 | plotstyle = cell(1,num); % default plot style 65 | [plotstyle{:}] = deal({".", 'MarkerSize', 25, 'LineWidth', 1.5}); 66 | end 67 | 68 | figure % plot 69 | hold on 70 | 71 | if iscell(noise) 72 | for i = 1:num 73 | errorbar(noise{i}, mean_fidelity{i}, err{i}, plotstyle{i}{:}) 74 | end 75 | else 76 | for i = 1:num 77 | errorbar(noise, mean_fidelity{i}, err{i}, plotstyle{i}{:}) 78 | end 79 | end 80 | 81 | % set plot properties 82 | if isfield(varargin, 'legend') || num > 1 83 | if isfield(varargin, 'legend') 84 | leg = varargin.('legend'); 85 | else 86 | leg = string(1:num); 87 | end 88 | if isfield(varargin, 'lposition') 89 | lpos = varargin.('lposition'); 90 | legend(leg, 'Position', [lpos(1),lpos(2),0,0]) 91 | else 92 | legend(leg, 'Location', 'southwest') 93 | end 94 | end 95 | ax = gca; 96 | ax.YLim = [0, 1.15]; 97 | ax.LineWidth = 1.5; 98 | ax.FontSize = 12; % ticks; if not explicitly set: labels, legend 99 | if isfield(varargin, 'xlabel') 100 | xlabel(varargin.('xlabel')) 101 | else 102 | xlabel('noise strength') 103 | end 104 | if isfield(varargin, 'ylabel') 105 | ylabel(varargin.('ylabel')) 106 | else 107 | ylabel('mean fidelity') 108 | end 109 | hold off 110 | 111 | if isfield(varargin, 'savename') % save 112 | savename = varargin.('savename'); 113 | savefig(strcat('Fig/dnvn_', savename, '.fig')) 114 | saveas(gcf, strcat('Fig/dnvn_', savename), 'png') 115 | saveas(gcf, strcat('Fig/dnvn_', savename), 'epsc') 116 | end 117 | end 118 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/QuickInitilizer.m: -------------------------------------------------------------------------------- 1 | function U = QuickInitilizer(M, varargin) 2 | % This functions quickly initializes a set of random unitaries for the 3 | % network with configuration M. 4 | % 5 | % optional in as name/value pairs (function(..., 'name', value, ...)): 6 | % sparse: cell array S defining the sparsity of the neural network; 7 | % for the k-th layer in M, the j-th neuron in this layer, 8 | % and its connection to the i-th neuron in the (k-1)-th layer, 9 | % S{k-1}(j,i) is either zero or one, where 1 means connected; 10 | % default is a fully connected network 11 | % out: 12 | % The unitaries for each layer are stored in the cell array U. 13 | % U{k}(:,:,j) is the unitary belonging to the jth neuron in the kth layer. 14 | % If sparse, U{k}(:,:,j) acts as an identity on disconnected qubits. 15 | 16 | if rem(length(varargin), 2) == 1 % test that optional input is paired 17 | error('Provide the optional input arguments as name/value pairs.') 18 | end 19 | varargin = cell2struct(varargin(2:2:end), varargin(1:2:end), 2); 20 | 21 | N_NumLay = size(M,2); 22 | 23 | if ~isfield(varargin, 'sparse') % fully connected 24 | for k = 2:N_NumLay 25 | for j = 1:M(k) 26 | U{k}(:,:,j) = Randomunitary(2^(M(k-1)+1)); 27 | end 28 | end 29 | else 30 | sparsity = varargin.('sparse'); % sparse 31 | for k = 2:N_NumLay 32 | for j = 1:M(k) 33 | NumBonds = M(k-1); % number of connections if fully connected 34 | bonds = 1:NumBonds; 35 | cut = bonds(~sparsity{k-1}(j,:)); % indices of connections to cut 36 | NumCut = length(cut); % number of connections to cut 37 | % random unitary acting on (NumBonds-NumCut+1) qubits 38 | % tensored with identities on NumCut qubits: 39 | Ukj = kron(Randomunitary(2^(NumBonds-NumCut+1)), eye(2^NumCut)); 40 | for i = 1:NumCut % swap identities to disconnected qubits 41 | Ukj = Swap(Ukj, [cut(i), NumBonds+2-i], 2*ones(1, NumBonds+1)); 42 | end 43 | U{k}(:,:,j) = Ukj; 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/RandomUnitary1.m: -------------------------------------------------------------------------------- 1 | function U = RandomUnitary1(dim,t,n) 2 | %RandomUnitary1(deviation) creates a dim-dimensional unitary close to identiry. 3 | %For t=0 the answer is identity, for large enough t 4 | %(for practical purpouses, t~1) 5 | %the answer is a unitary sampled from Haar distribution. 6 | %The error to Texp(\int_0^t i \pi H(t) dt ) with random H(t) scales as 1/sqrt(n). 7 | 8 | U = BrownianCircuit(dim,n,sqrt(1/(n*dim))*2*pi*t); 9 | end 10 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/RandomUnitaryTrainingsData.m: -------------------------------------------------------------------------------- 1 | %Generates an array of random trainings data, where for each the output 2 | %state is the image of the input state under a given (randomly chosenn) 3 | %unitary 4 | function [phi_in,phi_out,U] = RandomUnitaryTrainingsData (n,m) 5 | 6 | phi_in = randn(m,n) + i* randn(m,n); 7 | 8 | for j = 1:n 9 | phi_in(: ,j) = (phi_in(: ,j))/norm(phi_in(: ,j)); 10 | end 11 | 12 | U = Randomunitary(m); 13 | 14 | phi_out = zeros(m,n); 15 | 16 | for j =1:n 17 | 18 | phi_out(:,j) = U *phi_in(:,j); 19 | end 20 | 21 | end 22 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/Randomtrainingdata.m: -------------------------------------------------------------------------------- 1 | %Generates an array of random input and output vectors 2 | function [phi_in,phi_out] = Randomtrainingdata(n,m) 3 | 4 | phi_in = randn(m,n) + i*randn(m,n); 5 | 6 | for j = 1:n 7 | phi_in(: ,j) = (phi_in(: ,j))/norm(phi_in(: ,j)); 8 | end 9 | 10 | phi_out = randn(m,n) + i*randn(m,n); 11 | 12 | for j = 1:n 13 | phi_out(: ,j) = (phi_out(: ,j))/norm(phi_out(: ,j)); 14 | end 15 | 16 | end 17 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/Randomunitary.m: -------------------------------------------------------------------------------- 1 | %Creates a random unitary on \mathbb{C}^N 2 | function U = Randomunitary(N) 3 | 4 | U = zeros(N); 5 | 6 | U(:,1) = randn(N,1) + i*randn(N,1); 7 | U(:,1) = U(:,1) / norm(U(:,1)); 8 | for j= 2:N 9 | 10 | U(:,j) = randn(N,1) + i*randn(N,1); 11 | for k = 1:j-1 12 | psi = U(:,j); 13 | U(:,j) = U(:,j) - dot(U(:,k),psi)*U(:,k); 14 | end 15 | U(:,j) = U(:,j)/norm(U(:,j)); 16 | end 17 | 18 | 19 | end 20 | 21 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/SpectralRange.m: -------------------------------------------------------------------------------- 1 | function range = SpectralRange(A) 2 | %Outputs a spectral gap of a matrix A. 3 | 4 | range = norm(norm(A)*eye(size(A,1)) - A); 5 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/SpinFlipNoise.m: -------------------------------------------------------------------------------- 1 | function [psi_noisy, varargout] = SpinFlipNoise(psi, n, p) 2 | % SpinFlipNoise applies n times spin-flip noise to an m-qubit state psi 3 | % with spin-flip probability p per qubit 4 | % 5 | % in: 6 | % psi: noiseless m-qubit state in tensor product basis as column vector 7 | % n: number of noise realizations 8 | % p: spin-flip probability per qubit, maximal physical value is 0.5 9 | % out: 10 | % psi_noisy: psi_noisy(:,i) is the ith realization of a noisy psi 11 | % varargout: 12 | % {1}: n-element logical array v 13 | % with v(i)= 1 if psi_noisy(:,i) experienced only 0 or 1 spin-flips 14 | 15 | if p > 0.5 16 | error('Spin-flip probability per qubit greater than 0.5 is unphysical.') 17 | end 18 | 19 | dim = length(psi); % dimension of Hilbert space 20 | m = log2(dim); % number of qubits 21 | 22 | % define flips(:,:,i) as flip of ith spin 23 | flip1 = [0, 1; 1, 0]; % spin flip for one qubit 24 | id = eye(2); 25 | flips = zeros(dim, dim, m); 26 | for i = 1:m 27 | f = flip1; 28 | for j = 1:(i-1) 29 | f = kron(id, f); 30 | end 31 | for j = (i+1):m 32 | f = kron(f, id); 33 | end 34 | flips(:,:,i) = f; 35 | end 36 | 37 | % for every noise realization psi_noisy(:,i) and every qubit j 38 | % draw random number r(j) from uniform distribution in (0, 1) 39 | % and apply jth spin flip with probability p, i.e. if r(j) <= p 40 | psi_noisy = zeros(dim, n); 41 | varargout = zeros(n,1); 42 | for i = 1:n 43 | r = rand(m,1); % random numbers 44 | pn = psi; 45 | for j = 1:m 46 | if r(j) <= p 47 | pn = flips(:,:,j) * pn; % apply spin flip 48 | end 49 | end 50 | psi_noisy(:,i) = pn; 51 | nflips = (r <= p); 52 | if sum(nflips) <= 1 % maximally one spin flip 53 | varargout(i) = 1; 54 | end 55 | end 56 | varargout = {logical(varargout)}; 57 | end 58 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/TestRandomUnitary1.m: -------------------------------------------------------------------------------- 1 | %this script tests RandomUnitary1 2 | N=50; 3 | M=60; 4 | hold on 5 | for l=1:3 6 | for i=1:3 7 | x=zeros(1,M); 8 | for k=1:M 9 | for j= 1:N 10 | x(k)=x(k)+Fidelity(GHZ(l,0), RandomUnitary1(2^l,1.5*k/M,20*i*M/k)*GHZ(l,0)); 11 | end 12 | x(k)=x(k)/N; 13 | end 14 | plot(x) 15 | end 16 | end 17 | hold off 18 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/TrainNetwork.m: -------------------------------------------------------------------------------- 1 | function [U,CList] = TrainNetwork(phi_in,phi_out,U,M,lambda,iter,varargin) 2 | % Trains the Network and gives out the array with all trained unitaries in U 3 | % and an array CList with all Cost functions while training 4 | % 5 | % optional in as name/value pairs (function(..., 'name', value, ...)): 6 | % sparse: cell array S defining the sparsity of the neural network; 7 | % for the k-th layer in M, the j-th neuron in this layer, 8 | % and its connection to the i-th neuron in the (k-1)-th layer, 9 | % S{k-1}(j,i) is either zero or one, where 1 means connected; 10 | % default is a fully connected network 11 | % momentum: a number that is a momentum coefficient in a 12 | % gradient descent with momentum. 13 | % RMSprop: a number that is a memory coefficient in the RMSprop 14 | % gradient descent algorithm. 15 | % Cannot be used with Adam or Nadam. 16 | % Adam: a number that is a second momentum memory coefficient in the Adam 17 | % gradient descent algorithm. The first momentum coefficient in the Adam 18 | % is the number in the field 'momentum'. 19 | % Can not be used with RMSprop or Nadam. 20 | % Nadam: a number that is a second momentum memory coefficient in the Nadam 21 | % gradient descent algorithm. The first momentum coefficient in the Nadam 22 | % is the number in the field 'momentum'. 23 | % Can not be used with RMSprop or Adam. 24 | % A good overview of gradient descent algorithms can be found at 25 | % http://ruder.io/optimizing-gradient-descent/ 26 | % 27 | % out: 28 | % U: cell array of trained unitaries, 29 | % U{k}(:,:,j) belongs to the j-th neuron in the k-th layer; 30 | % if sparse, U{k}(:,:,j) acts as an identity on disconnected qubits 31 | % CList: array of cost functions for each training round 32 | 33 | %if_RMSprop = false; 34 | momentum_coefficient = 0; 35 | if_RMSprop = false; 36 | if_Adam = false; 37 | if_Nadam = false; 38 | 39 | if ~isempty(varargin) 40 | if rem(length(varargin), 2) == 1 % test that optional input is paired 41 | error('Provide the optional input arguments as name/value pairs.') 42 | end 43 | varargin = cell2struct(varargin(2:2:end), varargin(1:2:end), 2); 44 | 45 | if isfield(varargin, 'momentum') % get momentum coefficient 46 | momentum_coefficient = varargin.('momentum'); 47 | end 48 | if isfield(varargin, 'RMSprop') % define RMSprop coefficient 49 | if_RMSprop = true; 50 | RMSprop_coefficient = varargin.('RMSprop'); 51 | else 52 | if isfield(varargin, 'Adam') % define RMSprop coefficient 53 | if_Adam = true; 54 | RMSprop_coefficient = varargin.('Adam'); 55 | else 56 | if isfield(varargin, 'Nadam') % define RMSprop coefficient 57 | if_Nadam = true; 58 | RMSprop_coefficient = varargin.('Nadam'); 59 | end 60 | end 61 | end 62 | 63 | % check_sparse = cellfun(@(c) ischar(c) && strcmp(c, 'sparse'), varargin); 64 | % ind_sparse = find(check_sparse); 65 | % if ~isempty(ind_sparse) 66 | % sparse = true; 67 | % sparsity = varargin{ind_sparse+1}; 68 | % sparsity = cellfun(@(c) logical(c), sparsity, 'uo', false); 69 | % varargin = varargin([1:(ind_sparse-1), (ind_sparse+2):end]); 70 | % end 71 | end 72 | 73 | %iter: number of iterations the network trains (update all unitaries) 74 | eps= 0.1; 75 | 76 | N_NumTrain = size(phi_in,2); 77 | N_NumLay = size(M,2); 78 | 79 | CList = [CostNetwork(phi_in,phi_out,U,M)]; 80 | 81 | %Update the Unitaries iter time 82 | K ={}; 83 | PrevK ={}; %PrevK is the previous iteration of K update matrices, needed for momentum gradient descent. 84 | RenormL = {}; %RenormL is a list constant that renormalizes the learning rate for each K update matrix. 85 | 86 | for k = 2:N_NumLay 87 | if (if_RMSprop || momentum_coefficient || if_Adam || if_Nadam) 88 | PrevK{k}=zeros(2^(M(k-1)+1),2^(M(k-1)+1),M(k)); 89 | if (if_RMSprop || if_Adam || if_Nadam) 90 | RenormL{k} = zeros(M(k)); 91 | end 92 | end 93 | end 94 | 95 | for round=2:iter 96 | %UpdateMatrix = {}; % UpdateMatrix is the matrix that include the momentum and constant renormalization terms. 97 | 98 | %Generating all K Update Matrices 99 | for x = 1:N_NumTrain 100 | 101 | for k = 2:N_NumLay 102 | %Initilize a state to calculate state of left side of the Commutator in the Update Matrix M 103 | %i.e. the one coming from the \mathcal{E} or "ApplyLayer" Channel. 104 | if x == 1 105 | K{k} = zeros(2^(M(k-1)+1),2^(M(k-1)+1),M(k)); 106 | end 107 | 108 | if k == 2 109 | rho_left_prev = phi_in(:,x)*phi_in(:,x)'; 110 | else 111 | rho_left_prev = ApplyLayer(rho_left_prev,U{k-1},M(k-1),M(k-2)); 112 | end 113 | rho_left = kron(rho_left_prev,[1;zeros(2^M(k)-1,1)]*[1;zeros(2^M(k)-1,1)]'); 114 | 115 | for j = 1:M(k) 116 | %Initilize a state to calculate the state of the right hand side 117 | %of the Commutator in the Update Matrix M, i.e. the one coming 118 | %from the conjugate F Channel. 119 | if k==2 && j==1 120 | for k_1 = 2:N_NumLay 121 | k_2 = N_NumLay -k_1 +2; 122 | if k_2 == N_NumLay 123 | rho_right_prev = phi_out(:,x)*phi_out(:,x)'; 124 | else 125 | rho_right_prev = FChannel(rho_right_prev,U{k_2+1},M(k_2 +1),M(k_2)); 126 | end 127 | rho_right{k_2} = kron(eye(2^M(k_2-1)),rho_right_prev); 128 | for j_1 = 1:M(k_2) 129 | j_2 = M(k_2) -j_1 +1; 130 | V = Swap(kron(U{k_2}(:,:,j_2),eye(2^(M(k_2)-1))),[M(k_2-1)+1,M(k_2-1)+j_2],2*ones(1,M(k_2-1)+M(k_2))); 131 | rho_right{k_2} = V'*rho_right{k_2}*V; 132 | end 133 | end 134 | end 135 | 136 | %Generating left hand side of commutator for M_j^k. Note that we can use application 137 | %of all unitaries before the _j^k Neuron 138 | V = Swap(kron(U{k}(:,:,j),eye(2^(M(k)-1))),[M(k-1)+1,M(k-1)+j],2*ones(1,M(k-1)+M(k))); 139 | rho_left = V*rho_left*V'; 140 | 141 | rho_right{k} = V*rho_right{k}*V'; 142 | 143 | M_Update = Comm(rho_left,rho_right{k}); 144 | 145 | Kxkj = PartialTrace(M_Update, [M(k-1)+1:M(k-1)+j-1,M(k-1)+j+1:M(k-1)+M(k)], 2*ones(1,M(k-1)+M(k))); 146 | 147 | if isfield(varargin, 'sparse') 148 | sparsity = varargin.('sparse'); 149 | sparsity = cellfun(@(c) logical(c), sparsity, 'UniformOutput', false); % convert sparsity to logical 150 | NumBonds = M(k-1); % number of connections if fully connected 151 | bonds = 1:NumBonds; 152 | cut = bonds(~sparsity{k-1}(j,:)); % indices of connections to cut 153 | NumCut = length(cut); % number of connections to cut 154 | if NumCut > 0 155 | NumQbits = NumBonds + NumCut + 1; 156 | % parameter matrix for fully connected case 157 | % tensored with identities on NumCut qubits: 158 | K_sparse = kron(Kxkj, eye(2^NumCut)); 159 | for i = 1:NumCut % swap identities to disconnected qubits 160 | K_sparse = Swap(K_sparse, [cut(i), NumQbits+1-i], 2*ones(1, NumQbits)); 161 | end 162 | % partial trace over swapped disconnected qubits: 163 | Kxkj = PartialTrace(K_sparse, NumQbits+1-(1:NumCut), 2*ones(1, NumQbits)); 164 | end 165 | end 166 | K{k}(:,:,j) = K{k}(:,:,j) + Kxkj; 167 | end 168 | end 169 | end 170 | 171 | %Updating all Unitaries in the Network 172 | momentum = 0; %Initialization of momentum term. 173 | 174 | for k = 2:N_NumLay 175 | % if ((if_RMSprop || momentum_coefficient || if_Adam || if_Nadam) && (round == 2)) 176 | % PrevK{k}=K{k}; 177 | % if (if_RMSprop || if_Adam || if_Nadam) 178 | % RenormL{k} = zeros(M(k)); 179 | % end 180 | % end 181 | for j = 1:M(k) 182 | K{k}(:,:,j) = (2^M(k-1))*K{k}(:,:,j); 183 | %UpdateMatrix{k}(:,:,j) = K{k}(:,:,j); 184 | if momentum_coefficient 185 | momentum = momentum_coefficient*PrevK{k}(:,:,j); %Momentum term. 186 | if (if_Adam || if_Nadam) 187 | momentum = momentum +(1 - momentum_coefficient)*K{k}(:,:,j); 188 | PrevK{k}(:,:,j) = momentum; 189 | momentum = momentum /(1 - momentum_coefficient^round); 190 | else 191 | %PrevK{k}(:,:,j) = momentum + K{k}(:,:,j); 192 | end 193 | end 194 | if (if_RMSprop || if_Adam || if_Nadam) 195 | RenormL{k}(j) = RMSprop_coefficient*RenormL{k}(j)+... 196 | (1-RMSprop_coefficient)*SpectralRange(K{k}(:,:,j)^2); 197 | if if_RMSprop 198 | %UpdateMatrix{k}(:,:,j) = K{k}(:,:,j)/sqrt(RenormL{k}(j) + min([eps, 1])^16) + momentum; 199 | momentum = K{k}(:,:,j)/sqrt(RenormL{k}(j) + min([eps, 1])^16) + momentum; 200 | PrevK{k}(:,:,j) = momentum; 201 | %RMSprop algorithm for learning rate renormalization 202 | else 203 | %RenormL{k}(j) = RenormL{k}(j)/(1 - RMSprop_coefficient^round); 204 | if if_Nadam 205 | momentum = momentum_coefficient* momentum + ... 206 | ((1-momentum_coefficient)/(1-momentum_coefficient^round))* K{k}(:,:,j); 207 | end 208 | %UpdateMatrix{k}(:,:,j) = momentum /(sqrt(RenormL{k}(j)) + min([eps, 1])^8); 209 | momentum = momentum /... 210 | (sqrt(RenormL{k}(j)/(1 - RMSprop_coefficient^round)) + min([eps, 1])^8); 211 | end 212 | else 213 | %UpdateMatrix{k}(:,:,j) = K{k}(:,:,j) + momentum; 214 | %fprintf('M=%1.5f',momentum_coefficient); 215 | if momentum_coefficient 216 | momentum = K{k}(:,:,j) + momentum; 217 | else 218 | momentum = K{k}(:,:,j); 219 | end 220 | end 221 | %U{k}(:,:,j) =expm((-eps*2^M(k-1)/(N_NumTrain*lambda))*K{k}(:,:,j))*U{k}(:,:,j); 222 | %U{k}(:,:,j) =expm((-eps/(lambda*N_NumTrain))*UpdateMatrix{k}(:,:,j))*U{k}(:,:,j); 223 | U{k}(:,:,j) =expm((-eps/(lambda*N_NumTrain))*momentum)*U{k}(:,:,j); 224 | end 225 | end 226 | 227 | %Save the cost function of this round 228 | c = CostNetwork(phi_in,phi_out,U,M); 229 | CList(round) = c; 230 | disp(c) 231 | 232 | end 233 | 234 | end 235 | -------------------------------------------------------------------------------- /DQNN/DeepQNN-MATLAB/UnitaryNoise.m: -------------------------------------------------------------------------------- 1 | function psi_noisy = UnitaryNoise(psi, n, t, q) 2 | % SpinFlipNoise applies n times spin-flip noise to a state psi 3 | % with noise parameter t and number of noisy gates q. 4 | % 5 | % in: 6 | % psi: noiseless state. 7 | % n: number of noise realizations. 8 | % t: noise strength, "time" during which noise acts, around t=1 the noise is 9 | % so strong the distribution is essentially uniform. 10 | % q: number of noisy gates, controls how good of an approximation to 11 | % Brownian the noise is. 12 | % out: 13 | % psi_noisy: psi_noisy(:,i) is the ith realization of a noisy psi. 14 | 15 | dim = length(psi); % dimension of Hilbert space 16 | psi_noisy = zeros(dim, n); 17 | for i = 1:n 18 | psi_noisy(:,i) = RandomUnitary1(dim,t,q)*psi; 19 | end 20 | -------------------------------------------------------------------------------- /DQNN_on_NISQ/input/dqnn_2-2/input_training_states.txt: -------------------------------------------------------------------------------- 1 | (-4.929251356738192924e-01+2.340360553548553324e-01j) (-4.741684964312052331e-01-4.314188025091597600e-02j) (4.211381957137609322e-01+4.031670121359242076e-01j) (3.040701816120173762e-01+2.078346835017102767e-01j) 2 | (-2.853323241049805781e-02+2.440520799781159544e-01j) (3.847508745460964663e-01-6.336250188774834591e-01j) (6.499649625450904314e-03+1.683825931310362345e-01j) (-5.351626125632471531e-01-2.744386486899771938e-01j) 3 | (4.004486152285214873e-01+1.562615566883702178e-01j) (-7.310938856103275096e-01+4.999484096344127826e-01j) (7.805583094972602665e-02-2.068146466048390725e-02j) (8.379148982514007804e-02+1.312825239597047722e-01j) 4 | (-3.502986818817862003e-01+6.655738227900735993e-01j) (3.467845581043262904e-01+2.739948591908791808e-01j) (-2.796528886442487937e-03+4.591145687482266480e-01j) (-7.436800482435650117e-02+1.504825549145472896e-01j) 5 | -------------------------------------------------------------------------------- /DQNN_on_NISQ/input/dqnn_2-2/input_validation_states.txt: -------------------------------------------------------------------------------- 1 | (5.521068088681775343e-01-2.141949424248730804e-01j) (1.165768126529020676e-01-1.013743257213664262e-01j) (-3.949457432883028973e-01-6.132865385812102943e-01j) (3.042556360774092417e-01-2.752599582013649446e-02j) 2 | (-1.240594850595189980e-01-1.704066036035175313e-01j) (-4.291551937868151589e-01+3.490391304202751788e-01j) (5.314644145036477862e-01+4.444892377915392601e-01j) (-1.815007022964069683e-01+3.695953562560577721e-01j) 3 | (-5.156991747908908769e-02-6.178898406181512204e-01j) (3.373982634757639598e-01+7.221275535884696950e-03j) (6.142660824825073584e-01+2.545877379053714806e-01j) (-6.626504163746053944e-02-2.348066466943693475e-01j) 4 | (-2.303238150216882843e-02+3.888729970020879390e-01j) (-4.943795832251421940e-01+3.226143858483680460e-01j) (-6.322200585823135599e-01-2.320266513599370251e-01j) (-2.081538099550941934e-01+5.375415634921860975e-02j) 5 | -------------------------------------------------------------------------------- /DQNN_on_NISQ/input/dqnn_2-2/params.txt: -------------------------------------------------------------------------------- 1 | 0 0.6256274290363815 5.074702009076377 5.568401888677028 2.7840019799013187 1.3687901305234267 0.326639458271661 0.7244569273996514 6.152937270072831 5.563502709014203 1.528026984637191 3.296929262959445 5.245802253548842 4.427642462455877 2.013203212650262 3.318906092485352 1.2252019230441913 0.35191615170046703 1.4541126299080807 2.0786304332823873 6.03855265403888 1.4160612550806884 2.4826610044887323 0.35422530090290727 0.934110343204359 2 | -------------------------------------------------------------------------------- /DQNN_on_NISQ/input/dqnn_2-2/unitary.txt: -------------------------------------------------------------------------------- 1 | (-2.168993205332576668e-01+7.516304982398442913e-01j) (-3.980068810355329445e-01+8.222375730108616443e-02j) (-4.398279905244500965e-01+7.119462679049518017e-02j) (1.546719527362526714e-01+1.988230760588197144e-02j) 2 | (-1.420976907709209369e-01+1.661237766196724808e-01j) (4.832865598196148249e-01-5.276131422594528830e-01j) (-1.786559820590263026e-01+4.181271238927479761e-01j) (-1.228731354933182418e-01-4.673580546494956467e-01j) 3 | (3.790237619870207020e-02-1.111058790385158479e-01j) (1.229776820508411521e-02-3.240584038099363906e-01j) (3.906007570369136872e-02+4.324143062672323734e-01j) (6.407621357537716111e-01+5.310083548727041469e-01j) 4 | (-5.559655598379833474e-01-1.316761397624208185e-01j) (-5.877095840587253511e-02+4.628921471162291135e-01j) (2.123603812147553671e-01+6.009406450880677708e-01j) (-2.165211601347351578e-01+5.227352927492640022e-02j) 5 | -------------------------------------------------------------------------------- /DQNN_on_NISQ/input/qaoa_2qubits/input_training_states.txt: -------------------------------------------------------------------------------- 1 | (-9.921923501130792966e-02+3.485698509123184019e-01j) (1.445701988440109831e-01+2.938584155643207407e-01j) (7.353270721559211631e-02+1.911307078259986414e-01j) (-8.321890685896786710e-01+1.640872915928804632e-01j) 2 | (1.009706392862072394e-01+5.607783852750046760e-01j) (-2.568832151217821935e-01+5.666899075292132215e-01j) (-4.084688866964564791e-01+2.643662791006034518e-01j) (7.388911957098749650e-02-2.144997253802538306e-01j) 3 | (-3.601538932999849840e-01-1.820379685922611512e-01j) (-3.090544019285797472e-01+8.406861280730979491e-01j) (-8.705953205606908885e-02-1.435093452794202751e-01j) (-5.596028418895575285e-02+5.981399614503386808e-02j) 4 | (1.489520240099823367e-01-6.878815919370276366e-02j) (-2.518091897418634484e-01-3.876500666038617399e-02j) (1.944368125697823468e-02+7.958945391844743922e-01j) (-4.784998996670386529e-01-2.130318325799744616e-01j) 5 | -------------------------------------------------------------------------------- /DQNN_on_NISQ/input/qaoa_2qubits/input_validation_states.txt: -------------------------------------------------------------------------------- 1 | (-6.417907702101777190e-01-2.430340459858859048e-01j) (8.977213179548783339e-02-7.162538151648151913e-03j) (5.924544644171215735e-01-3.339824494493950913e-01j) (-2.263262233928781397e-01+8.460847369854644640e-02j) 2 | (1.876619703167214936e-01-2.149787814932037910e-01j) (-3.400452104452829083e-01+3.228511696264499964e-01j) (-3.451861552496474084e-01+4.073782706962450484e-01j) (5.383850383797705169e-02+6.408544014217200102e-01j) 3 | (5.827835177046118975e-01+1.102383652876369607e-01j) (3.578525614669368360e-01+6.776975061753052511e-03j) (-5.150730790250539481e-01-3.106844248872152603e-01j) (3.978143129220823027e-01-5.017469640661134482e-03j) 4 | (5.097192752876976707e-01+2.629165701581230863e-01j) (-4.868793765018055164e-01+2.845696806116302380e-01j) (-3.908553078352428045e-01+1.726605402570655923e-01j) (1.229115111319423054e-01-3.941356793753885701e-01j) 5 | -------------------------------------------------------------------------------- /DQNN_on_NISQ/input/qaoa_2qubits/matrix_A.txt: -------------------------------------------------------------------------------- 1 | (-1.021621144692042682e+00+0.000000000000000000e+00j) (-1.881928779699775678e+00-2.633948396418850924e-01j) (-3.918633299982743901e-01-1.186292964893396473e-01j) (9.877230434092513223e-01-3.883345525690362621e-02j) 2 | (-1.881928779699775678e+00+2.633948396418850924e-01j) (1.178553404732753940e+00+0.000000000000000000e+00j) (-2.457247912831982406e-01+1.151552210272066779e+00j) (-5.636410065338569308e-03-1.983087218644319361e+00j) 3 | (-3.918633299982743901e-01+1.186292964893396473e-01j) (-2.457247912831982406e-01-1.151552210272066779e+00j) (-1.585574001512302544e+00+0.000000000000000000e+00j) (-3.474094893748240764e-01-5.608193558514535937e-01j) 4 | (9.877230434092513223e-01+3.883345525690362621e-02j) (-5.636410065338569308e-03+1.983087218644319361e+00j) (-3.474094893748240764e-01+5.608193558514535937e-01j) (1.348076388901797484e+00+0.000000000000000000e+00j) 5 | -------------------------------------------------------------------------------- /DQNN_on_NISQ/input/qaoa_2qubits/matrix_B.txt: -------------------------------------------------------------------------------- 1 | (5.912632444001196808e-01+0.000000000000000000e+00j) (-3.284874658383353796e-01+6.714740524662583532e-01j) (5.383273225929939843e-01-7.898963801102149018e-01j) (-4.467272978125824689e-03+4.821430182734834924e-01j) 2 | (-3.284874658383353796e-01-6.714740524662583532e-01j) (2.225679073203029379e+00+0.000000000000000000e+00j) (1.942649711270293955e-01+1.200346681856777398e+00j) (5.041105046227831732e-01+5.219214725971207391e-01j) 3 | (5.383273225929939843e-01+7.898963801102149018e-01j) (1.942649711270293955e-01-1.200346681856777398e+00j) (-8.649585343594234921e-01+0.000000000000000000e+00j) (-5.048998189006759230e-01+3.205051510510788515e-01j) 4 | (-4.467272978125824689e-03-4.821430182734834924e-01j) (5.041105046227831732e-01-5.219214725971207391e-01j) (-5.048998189006759230e-01-3.205051510510788515e-01j) (-1.470316951922934434e+00+0.000000000000000000e+00j) 5 | -------------------------------------------------------------------------------- /DQNN_on_NISQ/input/qaoa_2qubits/unitary.txt: -------------------------------------------------------------------------------- 1 | (4.453476525811123077e-01-2.755782939398424003e-02j) (-7.476239218590847724e-01+2.978711098006953106e-01j) (-3.077000046039002346e-02-2.698120126261641660e-01j) (2.419634404349071954e-01+1.447262457086397336e-01j) 2 | (-4.193689041631103454e-01-1.494257784187216602e-02j) (-8.835436828051576597e-02-1.470160661040694761e-01j) (-4.292817529284492784e-01+2.229336682015358728e-01j) (6.338549091550991221e-01+3.984117641666385379e-01j) 3 | (6.044682181112661645e-01-3.404109828973462815e-01j) (3.694904830901014070e-01-3.114948422087891466e-01j) (2.428890902191427892e-01+8.789641268860490242e-02j) (4.625601475049212485e-01+6.710814129921598148e-02j) 4 | (2.047302533106424571e-01-3.188048546739370437e-01j) (-2.831973503073241805e-01-9.569776530961374150e-02j) (-2.207828735476826953e-01+7.594777642144571184e-01j) (-3.742880151125084209e-01+3.804098663708418981e-02j) 5 | -------------------------------------------------------------------------------- /DQNN_on_NISQ/main.py: -------------------------------------------------------------------------------- 1 | from user_config import api_token 2 | from qiskit import IBMQ # type: ignore 3 | 4 | import logging 5 | logger = logging.getLogger(__name__) 6 | logger.setLevel(logging.INFO) 7 | 8 | from execution import * 9 | 10 | if __name__ == "__main__": 11 | 12 | folder = "" 13 | 14 | # Load IBMQ account 15 | try: 16 | if api_token != '': 17 | IBMQ.enable_account(api_token) 18 | else: 19 | IBMQ.load_account() 20 | except: 21 | logger.error('Set your api_token in user_config.py or use IBMQ.save_account(your_api_token) on your machine once.') 22 | 23 | 24 | #################### Choose the runs you are interested in below #################### 25 | 26 | #### 1. Single training run with either DQNN or QAOA #### 27 | # Used for figure 3 in "Training Quantum Neural Networks on NISQ devices" 28 | 29 | ## a) Choose an input folder (unitary, training states, validation states, init parameters) 30 | # folder = "input/dqnn_2-2" 31 | # folder = "input/qaoa_2qubits" 32 | 33 | ## b) Choose settings for your training run 34 | single_execution( 35 | simulator=True, 36 | network=Network_DQNN(qnn_arch=[1,1], fidelity_measurement_method='destructive_swap'), 37 | # network=Network_QAOA(num_qubits=2, fidelity_measurement_method='destructive_swap', 38 | # A=folder+'/matrix_A.txt' if folder else None, B=folder+'/matrix_B.txt' if folder else None), 39 | shots=2**13, 40 | epochs=200, 41 | epsilon=0.25, 42 | eta=0.5, 43 | order_in_epsilon=2, 44 | gradient_method='gradient_descent', 45 | validation_step=1, 46 | load_unitary_from=folder+'/unitary.txt' if folder else None, 47 | load_params_from=folder+'/params.txt' if folder else None, 48 | load_training_states_from=folder+'/input_training_states.txt' if folder else None, 49 | load_validation_states_from=folder+'/input_validation_states.txt' if folder else None, 50 | device_name="ibmq_casablanca", 51 | optimization_level=3 52 | ) 53 | 54 | #### 2. Train DQNN and QAOA multiple times with different number of training pairs #### 55 | #### and for random unitaries, states and start parameters #### 56 | 57 | # Used for generalization analysis in figure 2a in "Training Quantum Neural Networks on NISQ devices" 58 | 59 | # train_for_different_start_parameters(num_runs=20, num_training_pairs=[1,2,3,4]) 60 | 61 | #### 3. Train DQNN and QAOA multiple times with different gate noise #### 62 | #### and for random unitaries, states and start parameters #### 63 | 64 | # Used for gate noise analysis in figure 2b in "Training Quantum Neural Networks on NISQ devices" 65 | 66 | # train_for_different_error_probabilities(num_runs=5) -------------------------------------------------------------------------------- /DQNN_on_NISQ/training_data.py: -------------------------------------------------------------------------------- 1 | import save_data as sd 2 | 3 | import scipy as sc # type: ignore 4 | import numpy as np # type: ignore 5 | from typing import Union, Optional, List, Tuple, Any 6 | 7 | def randomQubitUnitary(numQubits): 8 | """ 9 | returns a unitary 2^(numQubits)×2^(numQubits)-matrix 10 | as a numpy array (np.ndarray) that is the tensor product 11 | of numQubits factors. 12 | Before orthogonalization, it's elements are randomly picked 13 | out of a normal distribution. 14 | """ 15 | dim = 2**numQubits 16 | #Make unitary matrix 17 | res = sc.random.normal(size=(dim,dim)) + 1j * sc.random.normal(size=(dim,dim)) 18 | res = sc.linalg.orth(res) 19 | #Return 20 | return res 21 | 22 | def randomQubitState(numQubits): 23 | dim = 2**numQubits 24 | #Make normalized state 25 | res = sc.random.normal(size=(dim,1)) + 1j * sc.random.normal(size=(dim,1)) 26 | res = (1/sc.linalg.norm(res)) * res 27 | #Return 28 | return res.flatten() 29 | 30 | def generate_training_data(num_qubits: int, 31 | num_training_pairs: Optional[int] = None, 32 | num_validation_pairs: Optional[int] = None, 33 | network_unitary: Optional[Union[np.ndarray,List[complex],str]] = None, 34 | input_training_states: Optional[Union[List[np.ndarray],str]] = None, 35 | input_validation_states: Optional[Union[List[np.ndarray],str]] = None) -> Tuple[ 36 | List[List[np.ndarray]], 37 | List[List[np.ndarray]], np.ndarray]: 38 | """ 39 | generate_training_data is used to prepare a given number of training pairs 40 | for a given network architecture such that one training pair can be used 41 | to directly initialize the first 2m qubits of the circuit (m=network.num_qubits) 42 | 43 | Args: 44 | num_qubits: int 45 | num_training_pairs (optional, default: None): int 46 | num_validation_pairs (optional, default: None): int 47 | network_unitary (Optional[Union[np.ndarray,List[complex],str]], optional): Network unitary. Defaults to None. 48 | input_training_states (Optional[Union[List[np.ndarray],str]], optional): Input states to generate training pairs. Defaults to None. 49 | input_validation_states (Optional[Union[List[np.ndarray],str]], optional): Input states to generate validation pairs. Defaults to None. 50 | 51 | 52 | Returns: 53 | training pairs: list[[QubitState, Unitary*QubitState]] 54 | validation pairs: list[[QubitState, Unitary*QubitState]] 55 | network_unitary: np.ndarray 56 | """ 57 | if (num_training_pairs is None): num_training_pairs = 2**num_qubits 58 | if (num_validation_pairs is None): num_validation_pairs = 2**num_qubits 59 | if (network_unitary is None): network_unitary = randomQubitUnitary(num_qubits) 60 | if (isinstance(network_unitary, str)): 61 | network_unitary = np.asarray(np.loadtxt(network_unitary, dtype=complex)) 62 | assert len(network_unitary) == 2**num_qubits, "Dimension of network unitary {} does not match network architecture".format(np.shape(network_unitary)) 63 | 64 | # load training states 65 | input_states: List[np.ndarray] = [] 66 | if (input_training_states is None): 67 | input_states = [randomQubitState(num_qubits) for _ in range(num_training_pairs)] 68 | elif (isinstance(input_training_states, str)): 69 | input_states = [np.asarray(input_state) for input_state in np.loadtxt(input_training_states, dtype=complex)] 70 | sd.save_execution_info(load_training_states_from=input_training_states) 71 | else: 72 | input_states = input_training_states 73 | assert len(input_states) >= num_training_pairs, 'Number of input training states is smaller than given number of training pairs.' 74 | assert all((len(input_state) == 2**num_qubits) for input_state in input_states), 'Dimension of input training states does not match network architecture' 75 | 76 | # load validation states 77 | input_val_states: List[np.ndarray] = [] 78 | if (input_validation_states is None): 79 | input_val_states = [randomQubitState(num_qubits) for _ in range(num_validation_pairs)] 80 | elif (isinstance(input_validation_states, str)): 81 | input_val_states = [np.asarray(input_state) for input_state in np.loadtxt(input_validation_states, dtype=complex)] 82 | sd.save_execution_info(load_validation_states_from=input_validation_states) 83 | else: 84 | input_val_states = input_validation_states 85 | assert len(input_val_states) >= num_validation_pairs, 'Number of input validation states is smaller than given number of validation pairs.' 86 | assert all((len(input_val_state) == 2**num_qubits) for input_val_state in input_val_states), 'Dimension of input validation states does not match network architecture' 87 | 88 | train_and_val_pairs = [] 89 | for i in range(num_training_pairs): 90 | output_state = network_unitary.dot(input_states[i]) 91 | train_and_val_pairs.append([input_states[i], output_state]) 92 | for i in range(num_validation_pairs): 93 | output_state = network_unitary.dot(input_val_states[i]) 94 | train_and_val_pairs.append([input_val_states[i], output_state]) 95 | return np.array(train_and_val_pairs[:num_training_pairs]), np.array(train_and_val_pairs[num_training_pairs:]), network_unitary -------------------------------------------------------------------------------- /DQNN_on_NISQ/user_config.py: -------------------------------------------------------------------------------- 1 | # User configuration to access the IBM Quantum Experience 2 | # Find your information here: https://quantum-computing.ibm.com/account 3 | 4 | # Provider settings 5 | provider_info = { 6 | 'hub': 'ibm-q', 7 | 'group': 'open', 8 | 'project': 'main' 9 | } 10 | 11 | api_token = '' -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs1sv_3-1network_adjT0i65and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs1sv_3-1network_adjT0i65and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs1sv_3-1network_adjT0i65and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs1sv_3-1network_adjT0i65and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs1sv_3-1network_adjT0i65and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 0& 0& 1& 0& 0& 1& 1\\ 2 | 0& 1& 1& 1& 1& 1& 0& 0\\ 3 | 0& 1& 1& 0& 1& 1& 0& 0\\ 4 | 1& 1& 0& 1& 0& 0& 0& 0\\ 5 | 0& 1& 1& 0& 1& 1& 0& 0\\ 6 | 0& 1& 1& 0& 1& 1& 0& 0\\ 7 | 1& 0& 0& 0& 0& 0& 1& 1\\ 8 | 1& 0& 0& 0& 0& 0& 1& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs2sv_3-1network_adjT0i65and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs2sv_3-1network_adjT0i65and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs2sv_3-1network_adjT0i65and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs2sv_3-1network_adjT0i65and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs2sv_3-1network_adjT0i65and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 0& 0& 1& 0& 0& 1& 1\\ 2 | 0& 1& 1& 1& 1& 1& 0& 0\\ 3 | 0& 1& 1& 0& 1& 1& 0& 0\\ 4 | 1& 1& 0& 1& 0& 0& 0& 0\\ 5 | 0& 1& 1& 0& 1& 1& 0& 0\\ 6 | 0& 1& 1& 0& 1& 1& 0& 0\\ 7 | 1& 0& 0& 0& 0& 0& 1& 1\\ 8 | 1& 0& 0& 0& 0& 0& 1& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs3sv_3-1network_adjT0i65and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs3sv_3-1network_adjT0i65and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs3sv_3-1network_adjT0i65and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs3sv_3-1network_adjT0i65and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs3sv_3-1network_adjT0i65and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 0& 0& 1& 0& 0& 1& 1\\ 2 | 0& 1& 1& 1& 1& 1& 0& 0\\ 3 | 0& 1& 1& 0& 1& 1& 0& 0\\ 4 | 1& 1& 0& 1& 0& 0& 0& 0\\ 5 | 0& 1& 1& 0& 1& 1& 0& 0\\ 6 | 0& 1& 1& 0& 1& 1& 0& 0\\ 7 | 1& 0& 0& 0& 0& 0& 1& 1\\ 8 | 1& 0& 0& 0& 0& 0& 1& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs4sv_3-1network_adjT0i65and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs4sv_3-1network_adjT0i65and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs4sv_3-1network_adjT0i65and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs4sv_3-1network_adjT0i65and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs4sv_3-1network_adjT0i65and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 0& 0& 1& 0& 0& 1& 1\\ 2 | 0& 1& 1& 1& 1& 1& 0& 0\\ 3 | 0& 1& 1& 0& 1& 1& 0& 0\\ 4 | 1& 1& 0& 1& 0& 0& 0& 0\\ 5 | 0& 1& 1& 0& 1& 1& 0& 0\\ 6 | 0& 1& 1& 0& 1& 1& 0& 0\\ 7 | 1& 0& 0& 0& 0& 0& 1& 1\\ 8 | 1& 0& 0& 0& 0& 0& 1& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs5sv_3-1network_adjT0i65and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs5sv_3-1network_adjT0i65and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs5sv_3-1network_adjT0i65and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs5sv_3-1network_adjT0i65and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs5sv_3-1network_adjT0i65and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 0& 0& 1& 0& 0& 1& 1\\ 2 | 0& 1& 1& 1& 1& 1& 0& 0\\ 3 | 0& 1& 1& 0& 1& 1& 0& 0\\ 4 | 1& 1& 0& 1& 0& 0& 0& 0\\ 5 | 0& 1& 1& 0& 1& 1& 0& 0\\ 6 | 0& 1& 1& 0& 1& 1& 0& 0\\ 7 | 1& 0& 0& 0& 0& 0& 1& 1\\ 8 | 1& 0& 0& 0& 0& 0& 1& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs6sv_3-1network_adjT0i65and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs6sv_3-1network_adjT0i65and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs6sv_3-1network_adjT0i65and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs6sv_3-1network_adjT0i65and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs6sv_3-1network_adjT0i65and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 0& 0& 1& 0& 0& 1& 1\\ 2 | 0& 1& 1& 1& 1& 1& 0& 0\\ 3 | 0& 1& 1& 0& 1& 1& 0& 0\\ 4 | 1& 1& 0& 1& 0& 0& 0& 0\\ 5 | 0& 1& 1& 0& 1& 1& 0& 0\\ 6 | 0& 1& 1& 0& 1& 1& 0& 0\\ 7 | 1& 0& 0& 0& 0& 0& 1& 1\\ 8 | 1& 0& 0& 0& 0& 0& 1& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs7sv_3-1network_adjT0i65and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs7sv_3-1network_adjT0i65and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs7sv_3-1network_adjT0i65and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs7sv_3-1network_adjT0i65and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs7sv_3-1network_adjT0i65and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 0& 0& 1& 0& 0& 1& 1\\ 2 | 0& 1& 1& 1& 1& 1& 0& 0\\ 3 | 0& 1& 1& 0& 1& 1& 0& 0\\ 4 | 1& 1& 0& 1& 0& 0& 0& 0\\ 5 | 0& 1& 1& 0& 1& 1& 0& 0\\ 6 | 0& 1& 1& 0& 1& 1& 0& 0\\ 7 | 1& 0& 0& 0& 0& 0& 1& 1\\ 8 | 1& 0& 0& 0& 0& 0& 1& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs8sv_3-1network_adjT0i65and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs8sv_3-1network_adjT0i65and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs8sv_3-1network_adjT0i65and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs8sv_3-1network_adjT0i65and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs8sv_3-1network_adjT0i65and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 0& 0& 1& 0& 0& 1& 1\\ 2 | 0& 1& 1& 1& 1& 1& 0& 0\\ 3 | 0& 1& 1& 0& 1& 1& 0& 0\\ 4 | 1& 1& 0& 1& 0& 0& 0& 0\\ 5 | 0& 1& 1& 0& 1& 1& 0& 0\\ 6 | 0& 1& 1& 0& 1& 1& 0& 0\\ 7 | 1& 0& 0& 0& 0& 0& 1& 1\\ 8 | 1& 0& 0& 0& 0& 0& 1& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs_1qubit_fidelities.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs_1qubit_fidelities.png -------------------------------------------------------------------------------- /GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs_1qubit_fidelities.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/connectedClustersRandomShuffled_8pairs_3-1network_adjT0i65and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/connectedClustersRandomShuffled_8pairs_1qubit_fidelities.txt -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/__pycache__/code.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/__pycache__/code.cpython-37.pyc -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs10sv_3-1network_adjT0i93and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs10sv_3-1network_adjT0i93and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs10sv_3-1network_adjT0i93and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs10sv_3-1network_adjT0i93and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs10sv_3-1network_adjT0i93and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 1& 0& 0& 0& 0& 0& 1& 0& 0\\ 2 | 1& 1& 0& 0& 0& 0& 1& 0& 0& 0\\ 3 | 0& 0& 1& 1& 0& 0& 0& 0& 1& 0\\ 4 | 0& 0& 1& 1& 0& 0& 0& 0& 0& 1\\ 5 | 0& 0& 0& 0& 1& 0& 0& 0& 1& 0\\ 6 | 0& 0& 0& 0& 0& 1& 1& 0& 0& 0\\ 7 | 0& 1& 0& 0& 0& 1& 1& 0& 0& 0\\ 8 | 1& 0& 0& 0& 0& 0& 0& 1& 0& 1\\ 9 | 0& 0& 1& 0& 1& 0& 0& 0& 1& 0\\ 10 | 0& 0& 0& 1& 0& 0& 0& 1& 0& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs1sv_3-1network_adjT0i93and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs1sv_3-1network_adjT0i93and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs1sv_3-1network_adjT0i93and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs1sv_3-1network_adjT0i93and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs1sv_3-1network_adjT0i93and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 1& 0& 0& 0& 0& 0& 1& 0& 0\\ 2 | 1& 1& 0& 0& 0& 0& 1& 0& 0& 0\\ 3 | 0& 0& 1& 1& 0& 0& 0& 0& 1& 0\\ 4 | 0& 0& 1& 1& 0& 0& 0& 0& 0& 1\\ 5 | 0& 0& 0& 0& 1& 0& 0& 0& 1& 0\\ 6 | 0& 0& 0& 0& 0& 1& 1& 0& 0& 0\\ 7 | 0& 1& 0& 0& 0& 1& 1& 0& 0& 0\\ 8 | 1& 0& 0& 0& 0& 0& 0& 1& 0& 1\\ 9 | 0& 0& 1& 0& 1& 0& 0& 0& 1& 0\\ 10 | 0& 0& 0& 1& 0& 0& 0& 1& 0& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs2sv_3-1network_adjT0i93and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs2sv_3-1network_adjT0i93and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs2sv_3-1network_adjT0i93and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs2sv_3-1network_adjT0i93and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs2sv_3-1network_adjT0i93and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 1& 0& 0& 0& 0& 0& 1& 0& 0\\ 2 | 1& 1& 0& 0& 0& 0& 1& 0& 0& 0\\ 3 | 0& 0& 1& 1& 0& 0& 0& 0& 1& 0\\ 4 | 0& 0& 1& 1& 0& 0& 0& 0& 0& 1\\ 5 | 0& 0& 0& 0& 1& 0& 0& 0& 1& 0\\ 6 | 0& 0& 0& 0& 0& 1& 1& 0& 0& 0\\ 7 | 0& 1& 0& 0& 0& 1& 1& 0& 0& 0\\ 8 | 1& 0& 0& 0& 0& 0& 0& 1& 0& 1\\ 9 | 0& 0& 1& 0& 1& 0& 0& 0& 1& 0\\ 10 | 0& 0& 0& 1& 0& 0& 0& 1& 0& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs3sv_3-1network_adjT0i93and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs3sv_3-1network_adjT0i93and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs3sv_3-1network_adjT0i93and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs3sv_3-1network_adjT0i93and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs3sv_3-1network_adjT0i93and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 1& 0& 0& 0& 0& 0& 1& 0& 0\\ 2 | 1& 1& 0& 0& 0& 0& 1& 0& 0& 0\\ 3 | 0& 0& 1& 1& 0& 0& 0& 0& 1& 0\\ 4 | 0& 0& 1& 1& 0& 0& 0& 0& 0& 1\\ 5 | 0& 0& 0& 0& 1& 0& 0& 0& 1& 0\\ 6 | 0& 0& 0& 0& 0& 1& 1& 0& 0& 0\\ 7 | 0& 1& 0& 0& 0& 1& 1& 0& 0& 0\\ 8 | 1& 0& 0& 0& 0& 0& 0& 1& 0& 1\\ 9 | 0& 0& 1& 0& 1& 0& 0& 0& 1& 0\\ 10 | 0& 0& 0& 1& 0& 0& 0& 1& 0& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs4sv_3-1network_adjT0i93and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs4sv_3-1network_adjT0i93and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs4sv_3-1network_adjT0i93and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs4sv_3-1network_adjT0i93and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs4sv_3-1network_adjT0i93and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 1& 0& 0& 0& 0& 0& 1& 0& 0\\ 2 | 1& 1& 0& 0& 0& 0& 1& 0& 0& 0\\ 3 | 0& 0& 1& 1& 0& 0& 0& 0& 1& 0\\ 4 | 0& 0& 1& 1& 0& 0& 0& 0& 0& 1\\ 5 | 0& 0& 0& 0& 1& 0& 0& 0& 1& 0\\ 6 | 0& 0& 0& 0& 0& 1& 1& 0& 0& 0\\ 7 | 0& 1& 0& 0& 0& 1& 1& 0& 0& 0\\ 8 | 1& 0& 0& 0& 0& 0& 0& 1& 0& 1\\ 9 | 0& 0& 1& 0& 1& 0& 0& 0& 1& 0\\ 10 | 0& 0& 0& 1& 0& 0& 0& 1& 0& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs5sv_3-1network_adjT0i93and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs5sv_3-1network_adjT0i93and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs5sv_3-1network_adjT0i93and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs5sv_3-1network_adjT0i93and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs5sv_3-1network_adjT0i93and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 1& 0& 0& 0& 0& 0& 1& 0& 0\\ 2 | 1& 1& 0& 0& 0& 0& 1& 0& 0& 0\\ 3 | 0& 0& 1& 1& 0& 0& 0& 0& 1& 0\\ 4 | 0& 0& 1& 1& 0& 0& 0& 0& 0& 1\\ 5 | 0& 0& 0& 0& 1& 0& 0& 0& 1& 0\\ 6 | 0& 0& 0& 0& 0& 1& 1& 0& 0& 0\\ 7 | 0& 1& 0& 0& 0& 1& 1& 0& 0& 0\\ 8 | 1& 0& 0& 0& 0& 0& 0& 1& 0& 1\\ 9 | 0& 0& 1& 0& 1& 0& 0& 0& 1& 0\\ 10 | 0& 0& 0& 1& 0& 0& 0& 1& 0& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs6sv_3-1network_adjT0i93and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs6sv_3-1network_adjT0i93and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs6sv_3-1network_adjT0i93and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs6sv_3-1network_adjT0i93and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs6sv_3-1network_adjT0i93and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 1& 0& 0& 0& 0& 0& 1& 0& 0\\ 2 | 1& 1& 0& 0& 0& 0& 1& 0& 0& 0\\ 3 | 0& 0& 1& 1& 0& 0& 0& 0& 1& 0\\ 4 | 0& 0& 1& 1& 0& 0& 0& 0& 0& 1\\ 5 | 0& 0& 0& 0& 1& 0& 0& 0& 1& 0\\ 6 | 0& 0& 0& 0& 0& 1& 1& 0& 0& 0\\ 7 | 0& 1& 0& 0& 0& 1& 1& 0& 0& 0\\ 8 | 1& 0& 0& 0& 0& 0& 0& 1& 0& 1\\ 9 | 0& 0& 1& 0& 1& 0& 0& 0& 1& 0\\ 10 | 0& 0& 0& 1& 0& 0& 0& 1& 0& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs7sv_3-1network_adjT0i93and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs7sv_3-1network_adjT0i93and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs7sv_3-1network_adjT0i93and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs7sv_3-1network_adjT0i93and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs7sv_3-1network_adjT0i93and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 1& 0& 0& 0& 0& 0& 1& 0& 0\\ 2 | 1& 1& 0& 0& 0& 0& 1& 0& 0& 0\\ 3 | 0& 0& 1& 1& 0& 0& 0& 0& 1& 0\\ 4 | 0& 0& 1& 1& 0& 0& 0& 0& 0& 1\\ 5 | 0& 0& 0& 0& 1& 0& 0& 0& 1& 0\\ 6 | 0& 0& 0& 0& 0& 1& 1& 0& 0& 0\\ 7 | 0& 1& 0& 0& 0& 1& 1& 0& 0& 0\\ 8 | 1& 0& 0& 0& 0& 0& 0& 1& 0& 1\\ 9 | 0& 0& 1& 0& 1& 0& 0& 0& 1& 0\\ 10 | 0& 0& 0& 1& 0& 0& 0& 1& 0& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs8sv_3-1network_adjT0i93and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs8sv_3-1network_adjT0i93and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs8sv_3-1network_adjT0i93and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs8sv_3-1network_adjT0i93and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs8sv_3-1network_adjT0i93and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 1& 0& 0& 0& 0& 0& 1& 0& 0\\ 2 | 1& 1& 0& 0& 0& 0& 1& 0& 0& 0\\ 3 | 0& 0& 1& 1& 0& 0& 0& 0& 1& 0\\ 4 | 0& 0& 1& 1& 0& 0& 0& 0& 0& 1\\ 5 | 0& 0& 0& 0& 1& 0& 0& 0& 1& 0\\ 6 | 0& 0& 0& 0& 0& 1& 1& 0& 0& 0\\ 7 | 0& 1& 0& 0& 0& 1& 1& 0& 0& 0\\ 8 | 1& 0& 0& 0& 0& 0& 0& 1& 0& 1\\ 9 | 0& 0& 1& 0& 1& 0& 0& 0& 1& 0\\ 10 | 0& 0& 0& 1& 0& 0& 0& 1& 0& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs9sv_3-1network_adjT0i93and1_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs9sv_3-1network_adjT0i93and1_graph.png -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs9sv_3-1network_adjT0i93and1_graph.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs9sv_3-1network_adjT0i93and1_graph.txt -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs9sv_3-1network_adjT0i93and1_matrix.txt: -------------------------------------------------------------------------------- 1 | begin{pmatrix}1& 1& 0& 0& 0& 0& 0& 1& 0& 0\\ 2 | 1& 1& 0& 0& 0& 0& 1& 0& 0& 0\\ 3 | 0& 0& 1& 1& 0& 0& 0& 0& 1& 0\\ 4 | 0& 0& 1& 1& 0& 0& 0& 0& 0& 1\\ 5 | 0& 0& 0& 0& 1& 0& 0& 0& 1& 0\\ 6 | 0& 0& 0& 0& 0& 1& 1& 0& 0& 0\\ 7 | 0& 1& 0& 0& 0& 1& 1& 0& 0& 0\\ 8 | 1& 0& 0& 0& 0& 0& 0& 1& 0& 1\\ 9 | 0& 0& 1& 0& 1& 0& 0& 0& 1& 0\\ 10 | 0& 0& 0& 1& 0& 0& 0& 1& 0& 1\end{pmatrix} -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs_1qubit_fidelities.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs_1qubit_fidelities.png -------------------------------------------------------------------------------- /GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs_1qubit_fidelities.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qigitphannover/DeepQuantumNeuralNetworks/9906aafc5ed23d329d6cb21fd1d22d826bf24d49/GraphQNN/lineOutputRandomShuffled_10pairs_3-1network_adjT0i93and1_g-0i5_delta0_lda1_ep0i01_rounds1000_shots30_plotmean/lineOutputRandomShuffled_10pairs_1qubit_fidelities.txt -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 QIG ITP Hannover 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dissipative Quantum Neural Networks 2 | This code can be used to classically simulate deep quantum neural networks. The basic idea is presented in the Jupyter notebook __DQNN_basic.ipynb__. Further code can be found in the folder __DQNN__. The DQNNs are proposed in 3 | * K. Beer, D. Bondarenko, T. Farrelly, T. J. Osborne, R. Salzmann, and R. Wolf. Training deep quantum neural networks. Nat Commun 11, 808 (2020). https://doi.org/10.1038/s41467-020-14454-2 4 | 5 | The same code is used to prepare the DQNN results in 6 | * Poland, K., Beer, K., & Osborne, T. J. (2020). No free lunch for quantum machine learning. https://arxiv.org/abs/2003.14103 7 | 8 | The folder __Qutoencoder-MATLAB__ contains code used for 9 | * D. Bondarenko and P. Feldmann. Quantum Autoencoders to Denoise Quantum Data. Phys. Rev. Lett. 124, 130502 (2020) https://link.aps.org/doi/10.1103/PhysRevLett.124.130502 10 | 11 | In __GraphQNN__ the code of the following project is included 12 | * Beer, K., Khosla, M., Köhler, J., & Osborne, T. J. (2021). Quantum machine learning of graph-structured data. https://arxiv.org/abs/2103.10837 13 | 14 | Found code in __DQNN_on_NISQ__ belongs to 15 | * Beer, K., List, D., Müller, G., Osborne, T. J., & Struckmann, C. (2021). Training Quantum Neural Networks on NISQ Devices. Beer, K., List, D., Müller, G., Osborne, T. J., & Struckmann, C. (2021). Training Quantum Neural Networks on NISQ Devices. https://arxiv.org/abs/2104.06081 16 | 17 | Moreover the folder __DQGAN__ presents code and resuls from 18 | * Beer, K., & Müller, G. (2021). Dissipative quantum generative adversarial networks. https://arxiv.org/abs/2112.06088 19 | --------------------------------------------------------------------------------