SaashaJoshi / piQture

piQture: A quantum machine learning library for image processing.
https://saashajoshi.github.io/piQture/
Apache License 2.0
15 stars 7 forks source link

Data Encoding classes should not require pixel_values #59

Closed SaashaJoshi closed 1 month ago

SaashaJoshi commented 5 months ago

Data encoding classes should not require a pixel_value argument such that the encoding technique can be used with SamplerQNN or EstimatorQNN primitives. The primitives, currently, require that the circuit or neural_network and the pixel_values or input_params be passed separately for model training purposes.

An ideal data encoding function should look like below:

def angle_encoding(img_dims: tuple[int, int]) -> QuantumCircuit:
    feature_dims = int(math.prod(img_dims))
    embedding = QuantumCircuit(feature_dims)
    feature_param = ParameterVector("Theta", feature_dims)
    for qubit in range(feature_dims):
        embedding.ry(feature_param[qubit], qubit)
    return embedding

The feature_param attribute should be accessible from outside the function/class as well. This can be built as a property method in an encoding class.

SaashaJoshi commented 1 month ago

QIR methods that encode pixel_vals in the basis state of the quantum circuit cannot be replaced with ParameterVector when the pixel_vals argument is None. The reason is that a basis state is created by converting the pixel values to a binary string, and until a ParameterVector is assigned integral values it cannot be converted to a binary format.

This incapability of defaulting pixel_vals to None also confirms that the current dependence of piQture on the Qiskti Machine Learning library and its neural_network module for classification cannot be utilized with QIR encodings that encode color information in the basis state of the quantum circuit (#35). This dependence must be removed, or the basis state encodings must be deemed incompatible with training neural networks and other QML models.