Magnetohydrosensor module¶
This code was taken from https://qml.baidu.com/tutorials/quantum-simulation/variational-quantum-metrology.html#2-variational-quantum-sensors we've modifide it by adding a class called MagnetoHydroSensor that takes as input the number of sensors and added a method to the class that take in a list of magnetic fields that are used to calibrate the sensor to increase it's sensitvity.
- magnetohydrosensor.MSE(qnn: Layer, phi: float) Tensor¶
Calculate MSE
- Parameters:
cir -- variational Ramsey interferometer
phi -- unknown parameter
a -- parameter of the estimator
- Returns:
MSE
- class magnetohydrosensor.MagnetoHydroSensor(default_field=0, sensors_count=10)¶
Bases:
object- feedback_loop(sensors_fields)¶
- plot()¶
- magnetohydrosensor.RamseyCircuit(theta_EN: Tensor, theta_DE: Tensor, input_phi: float) Circuit¶
Construct variational Ramsey interferometer
- Parameters:
theta_EN -- the parameters of encoding circuit, shape is [depth_En, num_qubits,3]
theta_DE -- the parameters of decoding circui, shape is [depth_De, num_qubits,3]
input_phi -- unknown parameter
- Returns:
Circuit
- class magnetohydrosensor.RamseyInterferometer¶
Bases:
LayerVariational Ramsey interferometer
- forward(fields_list) Tensor¶
Calculate loss
- opt(fields_list) None¶
Optimize QNN
- magnetohydrosensor.calculate_m(num_qubits: int) List[int]¶
- magnetohydrosensor.loss_func(qnn: Layer, magnetic_fields_list: list)¶
Calculate loss
- Parameters:
qnn -- a QNN
sampling_times -- the number of partitions in the selected interval
mean -- the mean of a normal distribution
variance -- the variance of a normal distribution
- magnetohydrosensor.optimization(qnn: Layer, fields_list, num_itr: int, learning_rate: float) None¶
Optimize QNN
- Parameters:
qnn -- a QNN
num_itr -- the number of optimization iterations
learning_rate -- learning rate
- magnetohydrosensor.std_dev(numbers)¶
This function takes a list of numbers as input and returns their standard deviation.
- magnetohydrosensor.std_mean(numbers)¶
This function takes a list of numbers as input and returns their mean.