p5.js web editor. ' Uncaught TypeError: Cannot read property 'split' of undefined (: line 57)'

Viewed 351

I recently started working on this project last few days from CodingTrain, however I kept running into this 'split' error. I've tried looking around how to fix it but I'm very new to JS. If anyone can help I would greatly appreciate it.

Sketch.js

 let brain;

function setup() {
  createCanvas(640, 480);
  let options = {
    inputs: 34,
    outputs: 4,
    task: 'classification',
    debug: true
  }
  brain = ml5.neuralNetwork(options);
  brain.loadData('ymca.json', dataReady);
}

function dataReady() {
  brain.normalizeData();
  brain.train({epochs: 50}, finished); 
}

function finished() {
  console.log('model trained');
  brain.save();
}

index.html 

    <!DOCTYPE html>
<html>

<head>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.10.2/p5.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.10.2/addons/p5.sound.min.js"></script>
  <script src="https://unpkg.com/ml5@0.5.0/dist/ml5.min.js"></script>
  <link rel="stylesheet" type="text/css" href="style.css">
  <meta charset="utf-8" />

</head>

<body>
  <script src="sketch.js"></script>
</body>

</html>
1 Answers

Split is reserved for strings so at some point looks like P5 is expecting a string but not getting it. You should be able to follow the error stack in your dev tools console and see what line of your code the error is coming from.

Related