No such file or directory #include <cstdarg>

having trouble with this code and this error message always appears: C:\Users\david\AppData\Local\Temp.arduinoIDE-unsaved2023125-1548-krtwrb.qn517\sketch_feb25a\sketch_feb25a.ino:2:10: fatal error: cstdarg: No such file or directory
#include
^~~~~~~~~
compilation terminated.

exit status 1

Compilation error: cstdarg: No such file or directory

here is the code i am trying to make work
#include <stdarg.h>
#include
#include <TinyMLShield.h>
#include <TensorFlowLite.h>

#include <Arduino_APDS9960.h>
#include <Arduino_LSM9DS1.h>
#include <Arduino_HTS221.h>

// Define the input and output layers of the neural network
const int input_nodes = 6;
const int output_nodes = 2;

// Define the number of hidden layers and nodes
const int num_layers = 2;
const int hidden_nodes = 10;

// Define the activation function for each layer
const tfl::ActivationFunctionType activation[num_layers+1] = {
tfl::ActivationFunctionType::kTfLiteActSigmoid,
tfl::ActivationFunctionType::kTfLiteActSigmoid,
tfl::ActivationFunctionType::kTfLiteActNone
};

// Define the loss function and optimizer for the neural network
const tfl::MicroMlOptimize::Type optimizer = tfl::MicroMlOptimize::kTfLiteMlOptimizeSgd;
const tfl::MicroMlModel::CompileOptions compile_options = {
.optimizer = optimizer,
.loss = tfl::MicroMlModel::kTfLiteMlLossMeanSquaredError
};

// Define the dataset of sensor readings and corresponding outputs
float inputs[NUM_SAMPLES][input_nodes];
float labels[NUM_SAMPLES][output_nodes];

void setup() {
// Initialize the sensors and collect data for the dataset
for (int i = 0; i < NUM_SAMPLES; i++) {
// Collect sensor readings and store in inputs[i]
// Collect corresponding output (e.g., robot movement) and store in labels[i]
}

// Define the neural network model
tfl::MicroMlModelRunner model_runner;
tfl::ErrorReporter* error_reporter = tfl::ArduinoErrorReporter();
const tfl::MicroMlModel* model = model_runner.CreateModel(error_reporter, input_nodes, output_nodes, num_layers, hidden_nodes, activation);

// Compile the neural network model
model_runner.Compile(model, compile_options);

// Train the neural network model on the dataset
model_runner.Train(inputs, labels, NUM_SAMPLES, 0);

// Save the trained neural network model to flash memory
model_runner.Save

Hello, do yourself a favour and please read How to get the best out of this forum and modify your post accordingly

āžœ please edit your post, select the code part and press the </> icon in the tool bar to mark it as code. It's barely readable as it stands. (also make sure you indented the code in the IDE before copying, that's done by pressing ctrlT on a PC or cmdT on a Mac)


you have an empty #include line in what we see...
image

(this is due to the missing code tags. when you fixed this we can help with the error message if you post if in full also within code tags)

#include <cstdarg> // Taken from the thread titile. Such files would usually have a .h at the end of the filename.

how do i fix this issue?
In file included from C:\Users\david\Documents\Arduino\libraries\Harvard_TinyMLx\src\tensorflow\lite\core\api\error_reporter.cpp:15:0:
C:\Users\david\Documents\Arduino\libraries\Harvard_TinyMLx\src/tensorflow/lite/core/api/error_reporter.h:18:10: fatal error: cstdarg: No such file or directory
#include
^~~~~~~~~
compilation terminated.

exit status 1

Compilation error: exit status 1

<cstdarg> without extension is correct: Standard library header <cstdarg> - cppreference.com

The issue is that the OP is trying to compile a library intended for more powerful ARM microcontrollers for AVR, and the AVR toolchain does not ship with the C++ standard library.

how do i fix the issue?

If you want to use the TensorFlow Lite library, you should use one of the supported microcontrollers: https://www.tensorflow.org/lite/microcontrollers#supported_platforms

may be by first showing a bit of respect for the forum and fixing your first post... ?

how do i fix my post?

by reading post 2