paddle_quantum.loss.distance

The source file of the class for the distance.

class paddle_quantum.loss.distance.TraceDistance(target_state)

Bases: Operator

The class of the loss function to compute the trace distance.

This interface can make you using the trace distance as the loss function.

Parameters:

target_state (State) – The target state to be used to compute the trace distance.

forward(state)

Compute the trace distance between the input state and the target state.

The value computed by this function can be used as a loss function to optimize.

Parameters:

state (State) – The input state which will be used to compute the trace distance with the target state.

Raises:

NotImplementedError – The backend is wrong or not supported.

Returns:

The trace distance between the input state and the target state.

Return type:

Tensor

class paddle_quantum.loss.distance.StateFidelity(target_state)

Bases: Operator

The class of the loss function to compute the state fidelity.

This interface can make you using the state fidelity as the loss function.

Parameters:

target_state (State) – The target state to be used to compute the state fidelity.

forward(state)

Compute the state fidelity between the input state and the target state.

The value computed by this function can be used as a loss function to optimize.

Parameters:

state (State) – The input state which will be used to compute the state fidelity with the target state.

Raises:

NotImplementedError – The backend is wrong or not supported.

Returns:

The state fidelity between the input state and the target state.

Return type:

Tensor