Skip to main content
ASalc.1
Associate II
January 3, 2022
Solved

How to build a multiple I/O npz file for validating with custom data?

  • January 3, 2022
  • 1 reply
  • 1989 views

I'm trying to build a .npz file with multiple input and output data.

I achieved to add just one input and output using this code:

np.savez('STM32TestData.npz',
 m_inputs_1=input_1,
 m_outputs_1=output_1,
 )
 
This works fine, but just one pair of data.

Adding more keys as 'm_inputs_2', 'm_outputs_2' didn't worked.

np.savez('STM32TestData.npz',
 m_inputs_1=input_1,
 m_outputs_1=output_1,
 m_inputs_2=input_2,
 m_outputs_2=output_2,
 ) 
 
 
E204(ValParamError): number of input arrays is invalid, 2 instead 1

Also I tried to save data as dictionaries with keys 'm_inputs_idx', 'm_outputs_idx' with 'idx' from 1 to N, but the same error occurred.

np.savez('STM32TestData.npz', **inputs_dict, **outputs_dict) 
 
E204(ValParamError): number of input arrays is invalid, 439 instead 1

What is the correct way to do it?

Additionally, what does 'c_inputs_<idx> and c_outputs_<idx> (multiple IO, if no m_inputs_<idx> keys are defined)' mean? How is it different from using 'm' version?

    This topic has been closed for replies.
    Best answer by Romain LE DONGE

    Hi @ASalc.1​  ,

    I had this usecase few weeks ago. I had a model with 1 input and 2 outputs, the correct way to handle it is to start from 0 index:

    np.savez('data_io.npz', m_inputs_0=X, m_outputs_0=out_0, m_outputs_1=out_1)

    "m_inputs/outputs_xx" are inputs/outputs related to the initial model execution

    "c_inputs/outputs_xx" are related to inputs and outputs from the C (stm.ai converted) model execution (Can be executed on STM32 or locally on desktop).

    Best regards,

    Romain

    1 reply

    Romain LE DONGE
    Romain LE DONGEBest answer
    Associate
    January 3, 2022

    Hi @ASalc.1​  ,

    I had this usecase few weeks ago. I had a model with 1 input and 2 outputs, the correct way to handle it is to start from 0 index:

    np.savez('data_io.npz', m_inputs_0=X, m_outputs_0=out_0, m_outputs_1=out_1)

    "m_inputs/outputs_xx" are inputs/outputs related to the initial model execution

    "c_inputs/outputs_xx" are related to inputs and outputs from the C (stm.ai converted) model execution (Can be executed on STM32 or locally on desktop).

    Best regards,

    Romain

    ASalc.1
    ASalc.1Author
    Associate II
    January 3, 2022

    Hi Romain, thanks for the answer, it solved my questions!.