# Use of Data loaders or State Initialization Circuits

I have recently started working on qiskit and I am struggling to use qc.initialize API in any practical or useful application. I have read at multiple places that they are used to feed data to the quantum circuits. For developing an understanding of the quantum computers, I executed the code of Bernstein Vazirani Algorithm(secret number detector) on qasm_simulator using Pycharm IDE as shown below without using any initialization circuit.

import qiskit
from qiskit import IBMQ
import time
from qiskit import *
from qiskit.tools.visualization import plot_histogram
from qiskit.tools.visualization import plot_bloch_multivector
import matplotlib.pyplot as plt
from qiskit.tools.monitor import job_monitor
#IBMQ.save_account('Account key',overwrite=True)  #  Run it for once

# 6 bit secret number
secretNumber= '101001'

circuit= QuantumCircuit(6+1,6) # 6 qubit for secret no. +1 qubit
circuit. h([0,1,2,3,4,5])
circuit.x(6)
circuit.h(6)
circuit.barrier()

# splitting the string into char
splitSecretNumber= list(secretNumber)
lengthofSecretNumber= len(splitSecretNumber)

x=0
while(x< lengthofSecretNumber):
if(str(splitSecretNumber[x])=='1'):
circuit.cx(int(x),6)
x=x+1

circuit.barrier()
circuit.h([0,1,2,3,4,5])
circuit.barrier()
circuit.measure([0,1,2,3,4,5],[0,1,2,3,4,5])
circuit.draw(output="mpl")

simulator= Aer.get_backend('qasm_simulator')
simulationResult = execute(circuit,simulator, shots=1).result()
counts= simulationResult.get_counts()
print(counts)
plot_histogram(simulationResult.get_counts(circuit))
plt.show()


Please guide me to convert this code to take Input data using initialization circuit. Also, please suggest me some good papers to read on initialization. Thanks in advance.

In your specific case of Bernstein Vazirani, you do not need to load anything in the amplitudes of the statevector as you only have one number, written in binary, that can be loaded by flipping qubits. You did exactly this with the cx gates in your while loop.
You can use the initialisation method described in your question when you want to load a vector of float numbers on the quantum computer. For example if you want to load $$\left[\frac{1}{10},\frac{4}{10},\frac{6}{10},\frac{47}{100}\right]$$ into the 2-qubit state $$\frac{1}{10} \vert 00 \rangle + \frac{4}{10}\vert 01 \rangle + \frac{6}{10} \vert 10 \rangle + \frac{47}{100} \vert 11 \rangle$$.