2024-06-22 11:08 AM
Hello everyone
I hope someone can help me
I have an ML model that consists of 2 inputs as shown in the picture. Is the code for the inputs correct?
float ML_input[WINDOW_SIZE*NUM_POINTS];
float Diff_input[WINDOW_SIZE*NUM_POINTS - NUM_POINTS];
static ai_float activations[AI_NETWORK_ADEM_DATA_ACTIVATIONS_SIZE];
static ai_float in_data[AI_NETWORK_ADEM_IN_1_SIZE_BYTES];
static ai_float out_data[AI_NETWORK_ADEM_OUT_1_SIZE_BYTES];
ai_handle adem_network = AI_HANDLE_NULL;
static ai_buffer *ai_input;
static ai_buffer *ai_output;
ai_i32 nbatch;
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_CAN2_Init();
MX_SPI1_Init();
MX_USART1_UART_Init();
MX_CRC_Init();
MX_USB_DEVICE_Init();
/* USER CODE BEGIN 2 */
Init_A121(); // Init sensor
ai_network_params ai_params = {AI_NETWORK_ADEM_DATA_WEIGHTS(ai_network_adem_data_weights_get()), AI_NETWORK_ADEM_DATA_ACTIVATIONS(activations)};
ai_error ai_err;
ai_input = ai_network_adem_inputs_get(adem_network, NULL);
ai_output = ai_network_adem_outputs_get(adem_network, NULL);
ai_err = ai_network_adem_create(&adem_network, AI_NETWORK_ADEM_DATA_CONFIG);
if(ai_err.type != AI_ERROR_NONE){while(1);}
if(!ai_network_adem_init(adem_network, &ai_params)){while(1);}
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
Measure_A121();
DeltaProprocessor(ML_input, Diff_input, NUM_POINTS, WINDOW_SIZE);
ai_input[0].data = AI_HANDLE_PTR((void*)ML_input);
ai_input[1].data = AI_HANDLE_PTR((void*)Diff_input);
ai_output[0].data = AI_HANDLE_PTR(out_data);
nbatch = ai_network_adem_run(adem_network, &ai_input[0], &ai_output[0]);
}
/* USER CODE END 3 */
}