qadence
qadence copied to clipboard
[Feature] Add helper functions to readily create QNNs
Currently, constructing QNNs requires a bunch of boilerplate code that needs to be repeated, especially when benchmarking different techniques relating to the definition of feature maps, ansatz and the observable used.
Have helper function build_qnn
that creates a Qadence QNN
and takes the configuration of the feature map (FeatureMapConfig
), of the ansatz (AnsatzConfig
) and the observable (ObservableConfig
).
fm_config = FeatureMapConfig(
num_features=1,
basis_set=BasisSet.CHEBYSHEV,
reupload_scaling=ReuploadScaling.TOWER,
feature_range=(-1.2, 1.2),
feature_map_strategy="digital",
multivariate_strategy="series",
)
ansatz_config = AnsatzConfig(
num_layers=2,
ansatz_type="hea",
ansatz_strategy="rydberg",
)
obs_config = ObservableConfig(detuning_strength="z")
f = build_qnn_model(
register=3,
fm_config=fm_config,
ansatz_config=ansatz_config,
observable_config=obs_config,
)
@smitchaudhary, for featuremaps we have: https://github.com/pasqal-io/qadence/blob/main/qadence/constructors/feature_maps.py#L133, for hamiltonians/observables: https://github.com/pasqal-io/qadence/blob/main/qadence/constructors/hamiltonians.py#L52 and for ansatz-related things: https://github.com/pasqal-io/qadence/blob/main/qadence/constructors/ansatze.py#L17. we of course welcome enhancements to those but maybe you have a look at it and communicate with @jpmoutinho about it