Skip to main content
ASalc.1
Associate II
Jan 3, 2022 2:39 PM UTC
Solved

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

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.
    Romain LE DONGE
    Romain LE DONGEBest answer
    Associate
    Jan 3, 2022 3:05 PM UTC

    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

    2 replies

    Romain LE DONGE
    Romain LE DONGEBest answer
    Associate
    Jan 3, 2022 3:05 PM UTC

    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
    Jan 3, 2022 3:32 PM UTC

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