Ml5-library: Uncaught Error: Based on the provided shape, [81], the tensor should have 81 values but has 162

Created on 9 Jul 2020  路  3Comments  路  Source: ml5js/ml5-library

With Simple Regression Code I am getting the Error

Uncaught Error: Based on the provided shape, [81], the tensor should have 81 values but has 162

Code to reproduce



let nn;
let counter = 0;

const options = {
  task:'regression',
  debug: true,
  inputs:2,
  outputs:1,
  epochs:32
}

function setup(){
  createCanvas(400, 400);
  nn = ml5.neuralNetwork(options);


  console.log(nn)
  createTrainingData();
  nn.normalizeData();

  const trainingOptions={
    batchSize: 24,
    epochs: 10
  }

  nn.train(trainingOptions);

}

function finishedTraining(){


    nn.predict([5], (err, results) => {
      if(err){
        console.log(err);
        return;
      }
      console.log(results[0]);
      let prediction = results[0]
      print(prediction);

    })
  }


function createTrainingData(){
  for(let i = 1; i < 10; i++){
    for(let j = 1; j < 10; j++){
      nn.addData([[i,j]], [j])
    }

  }
}



CLOSE ISSUE WHEN READY question

All 3 comments

@sps014 - Hi there! Thanks for your question + thanks for your understanding of any delays in response.
I believe this can be fixed by removing the extra brackets you had around the inputs of `nn.addData().

function createTrainingData(){
  for(let i = 1; i < 10; i++){
    for(let j = 1; j < 10; j++){
      nn.addData([i,j], [j])
    }

  }
}

If this resolves your issue, please feel free to close :) thanks!

@joeyklee Thanks , it worked

tysm 馃檹馃コ

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lastnod picture lastnod  路  4Comments

dianebecheras picture dianebecheras  路  6Comments

harshitmahendra picture harshitmahendra  路  3Comments

joeyklee picture joeyklee  路  5Comments

hlp-pls picture hlp-pls  路  9Comments