• I'm not entirely sure it matters. Even if you specify a 4D array, I believe internally Tensorflow flattens it into a 1D array which is what you see in Espruino, so it shouldn't matter too much.

    However, if you used a 1D array from the start, it might be less confusing as then it's very explicit what each part of the input represents

  • var tf = require("tensorflow").create(3072, model);
    
    function get_data(a){
    
    var d = [Math.round(a.x*100),Math.round(a.y*100),Math.round(a.z*100)];
      
    input_array.push(d);
    
    
    if (input_array.length > SAMPLE_SIZE-1){
    
    
    var row_array = [];
    var time_step_array = [];
    var final_input = [];
    var depth_array = [];
    
    for (i=0; i<input_array.length;i++){
        row_array = [];
        depth_array = [];
    
    for (j=0;j<input_array[0].length;j++){
        depth_array.push(input_array[i][j]);  
    }
    row_array.push(depth_array);
    time_step_array.push(row_array);
    }
    
    final_input.push(time_step_array);
    
    
    tf.getInput().set(final_input);
    
    //Terminal.println(tf.getInput());
    
    tf.invoke();
    
    Terminal.println(tf.getOutput());
    
    input_array = [];
    
    }
    
    
    }
    
    
    Bangle.on('accel', get_data);
    
    

    This is my code and my model takes input as array i am always getting the same output when printed. I am pretty sure there is no problem in model as i loaded the tflite model and tested the output in my desktop and it is working fine.

About

Avatar for user122861 @user122861 started