def feature_map():
    # BUILD FEATURE MAP HERE - START

    # import required qiskit libraries if additional libraries are required

    # build the feature map

    def self_product(x: np.ndarray) -> float:
        """
      Define a function map from R^n to R.

      Args:
        x: data

      Returns:
        float: the mapped value
      """
        coeff = x[0] if len(x) == 1 else \
          functools.reduce(lambda m, n:np.square( m * n), np.pi - x)
        return coeff

    feature_dim = 5  # equal to the dimension of the data

    feature_map = ZFeatureMap(feature_dimension=feature_dim,
                              data_map_func=self_product,
                              reps=2)
    feature_map.draw()
    # BUILD FEATURE MAP HERE - END

    #return the feature map which is either a FeatureMap or QuantumCircuit object
    return feature_map  # the write_and_run function writes the content in this cell into the file "variational_circuit.py"
Пример #2
0
def feature_map(): 
    # BUILD FEATURE MAP HERE - START
    
    # import required qiskit libraries if additional libraries are required
    
    # build the feature map
    feature_dim = 3     # equal to the dimension of the data

    feature_map = ZFeatureMap(feature_dimension=feature_dim, reps=4)
    feature_map.draw()
    # BUILD FEATURE MAP HERE - END
    
    #return the feature map which is either a FeatureMap or QuantumCircuit object
    return feature_map
Пример #3
0
def feature_map():
    # BUILD FEATURE MAP HERE - START

    # import required qiskit libraries if additional libraries are required

    # build the feature map

    feature_dim = 3  # equal to the dimension of the data

    feature_map = ZFeatureMap(feature_dimension=feature_dim, reps=2)
    feature_map.draw()
    # BUILD FEATURE MAP HERE - END

    #return the feature map which is either a FeatureMap or QuantumCircuit object
    return feature_map  # the write_and_run function writes the content in this cell into the file "variational_circuit.py"