Well, there are 14^2 = 196 circuit evaluations when you call the function
quanv. Then in this preprocessing code block, for every image in your dataset,
quanv gets called. Therefore, 196n circuit evaluations needs to happen, where n is the number of images in your dataset. It is a lot of circuit evaluations for you if n = 20,000. That part of your problem is unavoidable. Is the circuit the issue?
For the given circuit in the demo, there are 4 qubits and 2 layers (a
qml.RY layer and then one layer of
qml.templates.RandomLayers. I’m not entirely convinced that the circuit size is causing big runtime issues. Which leads me to the device!
dev = qml.device("lightning.qubit", wires=4) in place of the
"default.qubit" device. It’s a much faster simulator device that has a C++ backend .
Other than that, I’m not sure there are other things one can do to expedite the preprocessing. But, let me know how
"lightning.qubit works for you!