Question

Hello everybody I have the error that said:The call is ambiguous between the followings method. This is my code

      Matrix<int> layerSize = new Matrix<int>(new int[] { 400, 200,2  });

      MCvANN_MLP_TrainParams parameters = new MCvANN_MLP_TrainParams();
      parameters.term_crit = new MCvTermCriteria(10, 1.0e-8);
      parameters.train_method = Emgu.CV.ML.MlEnum.ANN_MLP_TRAIN_METHOD.BACKPROP;
      parameters.bp_dw_scale = 0.1;
      parameters.bp_moment_scale = 0.1;

      using (ANN_MLP network = new ANN_MLP(layerSize,   Emgu.CV.ML.MlEnum.ANN_MLP_ACTIVATION_FUNCTION.SIGMOID_SYM, 1.0, 1.0))
      {
          network.Train(train, clases, null, null, parameters, Emgu.CV.ML.MlEnum.ANN_MLP_TRAINING_FLAG.DEFAULT);


      }

I know that problem is that the compiler do not understand what method of property I want to use but using network.train() I have 3 options and the problem is that:

Train( Matrix trainData, Matrix responses, Matrix sampleWeights, Matrix sampleIdx, MCvANN_MLP_TrainParams parameters, ANN_MLP_TRAINING_FLAG flag )

Train( Matrix trainData, Matrix responses, Matrix sampleWeights, Matrix sampleMask, MCvANN_MLP_TrainParams parameters, ANN_MLP_TRAINING_FLAG flag )

I don't want to use Matrix sampleWeights,Matrix sampleMask for that reason I put null in both and so compiler do not know what constructor I want to use. Do you have any solution for that?

Was it helpful?

Solution

Both methods you mentioned have exact same signature due to which they cannot be overloaded at first place. I think you made a typo (at Matrix sampleMask).

However, to avoid such ambigous situation when you want to pass NULL or object type, you would need to typecast the parameters. For the current scenario you may have to modify the code as below.

network.Train(train, clases, (Matrix) null, (Matrix) null, parameters, Emgu.CV.ML.MlEnum.ANN_MLP_TRAINING_FLAG.DEFAULT);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top