• Members 2 posts
    Sept. 9, 2021, 9 p.m.

    I am using NeuralNetworkClassifier to fit a CircuitQNN for a classification of output_shape=4.

    output_shape = 4
    
    qnn = CircuitQNN(circuit=circuit,
                     input_params=list(feature_map.parameters),
                     weight_params=list(ansatz.parameters),
                     interpret=parity,
                     output_shape=output_shape,
                     gradient=Gradient(),
                     quantum_instance=q_instance)
    
    classifier = NeuralNetworkClassifier(qnn, optimizer=gd)
    

    gd is Qiskit's GradientDescent.

    classifier.fit(X_train, y_train)
    

    For several days, I have tried to rerun all the code on the notebook, but it keeps getting stuck at the fitting stage. My GradientDescent has maxiter=100, and my training data is 160 in length. Does the fitting usually take this long, or am I doing something wrong?

  • Members 19 posts
    Sept. 10, 2021, 9:36 p.m.

    There are many things that may cause long run time for machine learning problems. One of the common reason is that the NeuralNetworkClassifier cannot converge to the tolerance level you desire in GradientDescent. Have you try increasing the magnitude of tol to see if it converge within reasonable time? You may also want to simplify your model such as by reducing the complexity of your QuantumCircuit and the sample size & dimension of your training data to reduce resource needed for this experiment. Once you know if it is not a coding issue, you can change the setting back.

    If it still takes long run time, could you please post your full codes here, so that we can replicate your problem? :)