  We present a protocol for encoding $N$ real numbers stored in $N$ memory
registers into the amplitudes of the quantum superposition that describes the
state of $\log_2N$ qubits. This task is one of the main steps in quantum
machine learning algorithms applied to classical data. The protocol combines
partial CNOT gate rotations with probabilistic projection onto the desired
state. The number of additional ancilla qubits used during the implementation
of the protocol, as well as the number of quantum gates, scale linearly with
the number of qubits in the processing register and hence logarithmically with
$N$. The average time needed to successfully perform the encoding scales
logarithmically with the number of qubits, in addition to being inversely
proportional to the acceptable error in the encoded amplitudes. It also depends
on the structure of the data set in such a way that the protocol is most
efficient for non-sparse data.
