2024-12-05 03:29 AM
I am trying to validate a CNN on STM32CubeMX with X-Cube-AI 9.1.0. I provided a datainput.CSV and a dataoutput.csv files to "Validation inputs: & Validation outputs: " respectively. When ran Validate on desktop or Validate on target, they all failed >> "E204(ValParamError): number of data files is not enough, 4 are expected."
Could you please help me sort out this problem?
Do data files in .csv correct?
Only have 2 boxes for 2 files providing, why expected 4?
QS
Solved! Go to Solution.
2024-12-05 07:32 AM - edited 2024-12-05 07:34 AM
Could you share your model in a zip file? or send it to me in private message
I created a very simple CNN to test, and it worked with your input and output files:
import tensorflow as tf
from tensorflow.keras import layers, models
model = models.Sequential([layers.Conv1D(filters = 16, kernel_size = 2, activation = 'relu', input_shape=(9,1)),
layers.Flatten(),
layers.Dense(4, activation = 'softmax')
])
model.compile(optimizer='adam',
loss='sparse_categorial_crossentropy',
metrics=['accuracy'])
model.save("test.h5")
When activating CubeAI in CubeMX, you selected the Validation template right?
Julian
2024-12-05 05:11 AM
Hello @qs202310,
Your error is pretty strange, but in any case, you should use npy files.
For example, let's say that I have a model with an input size of 32x32x3 (RGB images) and 5 classes. I can generate two files containing 10 examples like this:
import numpy as np
# generate random images and labels
x_test = np.random.rand(10,32,32,3)
y_test = np.random.rand(10,5)
# Save one file for the inputs, another for the outputs
np.save("x_test.npy", x_test)
np.save("y_test.npy", y_test)
Then load these files in CubeAI:
Have a good day,
Julian
2024-12-05 06:18 AM
Many thanks Julian for your reply. I have changed the data files following your instruction. However, still got the same problem. I would like to upload the data files for your having a look, but here does not support the .npy format files.
Would you mind advise me trying anything else?
QS
2024-12-05 06:48 AM - edited 2024-12-05 06:48 AM
You can zip the files and attach the zip.
If you could add your model or at least give me your input shape and output shape.
It is my first time encountering the issue, but it makes me think of maybe an issue between the number of inputs and the number of outputs. Let's say you have 4 images but only 2 labels in your files? I don't know, we will see with your files.
Julian
2024-12-05 06:53 AM
2024-12-05 06:59 AM
This is the error:
2024-12-05 07:16 AM
Hello Julian,
Please do not be confused. The issue is not sorted out. I mistakenly pressed a button accepting the solution!
QS
2024-12-05 07:22 AM
Hello Julian,
If you need my AI model for working on this issue, I can email to you.
QS
2024-12-05 07:32 AM - edited 2024-12-05 07:34 AM
Could you share your model in a zip file? or send it to me in private message
I created a very simple CNN to test, and it worked with your input and output files:
import tensorflow as tf
from tensorflow.keras import layers, models
model = models.Sequential([layers.Conv1D(filters = 16, kernel_size = 2, activation = 'relu', input_shape=(9,1)),
layers.Flatten(),
layers.Dense(4, activation = 'softmax')
])
model.compile(optimizer='adam',
loss='sparse_categorial_crossentropy',
metrics=['accuracy'])
model.save("test.h5")
When activating CubeAI in CubeMX, you selected the Validation template right?
Julian
2024-12-05 07:47 PM
Many thanks Julian.
The issue has been sorted out by modifying the CNN model inputs >> Combines the three groups of inputs together. That is why 2 more data files are required by the validation.
QS