Skip to main content
Visitor II
May 23, 2025
Solved

Reason for abnormal similarity

  • May 23, 2025
  • 1 reply
  • 381 views

hello

        I would like to know the possible reasons for  anomalies.
        I used the AI library generated by NanoEdge AI Studio to run tests on STM32F407, and the similarity obtained was abnormal. Some exceed 100, such as 255, and I would like to know the possible reasons for such anomalies.

        Thanks.

Best answer by Julian E.

Hello @ScottO,

 

Most of the time it is due to an error in the init or the classification/detect function.

It could also be due to using the knowledge of another library than the one deployed, so make sure that all your linked files from NanoEdge are correct.

 

For my first point, please call the function like that

neai_state = neai_anomalydetection_init();
neai_state = neai_anomalydetection_knowledge(...);
neai_state = neai_anomalydetection_learn(...);
neai_state = neai_anomalydetection_detect();

and print the neai_state to see if you have any issue.

 

Here is the neai_state possible value and meaning:

enum neai_state {
	NEAI_OK = 0,
	NEAI_INIT_FCT_NOT_CALLED = 123,
	NEAI_BOARD_ERROR, 
	NEAI_KNOWLEDGE_BUFFER_ERROR,
	NEAI_NOT_ENOUGH_CALL_TO_LEARNING,
	NEAI_MINIMAL_RECOMMENDED_LEARNING_DONE,
	NEAI_UNKNOWN_ERROR
};
#endif

 

Make also sure to do enough learning:

 for (uint16_t iteration = 0 ; iteration < LEARNING_ITERATIONS ; iteration++) {
 fill_buffer(input_user_buffer);
 printf("learning %d/%d!\r\n",iteration,LEARNING_ITERATIONS);
 neai_anomalydetection_learn(input_user_buffer);
 }

 

Have a good day,

Julian

1 reply

Julian E.
Julian E.Best answer
Technical Moderator
May 23, 2025

Hello @ScottO,

 

Most of the time it is due to an error in the init or the classification/detect function.

It could also be due to using the knowledge of another library than the one deployed, so make sure that all your linked files from NanoEdge are correct.

 

For my first point, please call the function like that

neai_state = neai_anomalydetection_init();
neai_state = neai_anomalydetection_knowledge(...);
neai_state = neai_anomalydetection_learn(...);
neai_state = neai_anomalydetection_detect();

and print the neai_state to see if you have any issue.

 

Here is the neai_state possible value and meaning:

enum neai_state {
	NEAI_OK = 0,
	NEAI_INIT_FCT_NOT_CALLED = 123,
	NEAI_BOARD_ERROR, 
	NEAI_KNOWLEDGE_BUFFER_ERROR,
	NEAI_NOT_ENOUGH_CALL_TO_LEARNING,
	NEAI_MINIMAL_RECOMMENDED_LEARNING_DONE,
	NEAI_UNKNOWN_ERROR
};
#endif

 

Make also sure to do enough learning:

 for (uint16_t iteration = 0 ; iteration < LEARNING_ITERATIONS ; iteration++) {
 fill_buffer(input_user_buffer);
 printf("learning %d/%d!\r\n",iteration,LEARNING_ITERATIONS);
 neai_anomalydetection_learn(input_user_buffer);
 }

 

Have a good day,

Julian

​In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.