【问题标题】:Basic training of ML5 neural network not workingML5 神经网络的基础训练不起作用
【发布时间】:2021-03-07 21:57:15
【问题描述】:

我正在使用 ML5 来训练神经网络。 我正在加载一个包含泰坦尼克号数据的 CSV 文件。 This works when I download the demo file from the ML5 GitHub.

但是,当我使用不同的 CSV 文件并替换代码中的列名时,它会停止工作。我错过了什么吗?我的 CSV 文件包含数字,而演示文件包含字符串,是否存在问题?

let neuralNetwork

function start() {    
    const nnOptions = {
        dataUrl: "data/titanic.csv",
        inputs: ["Pclass", "Sex", "Age", "SibSp"],     // labels from my CSV file
        outputs: ["Survived"],
        task: "classification",
        debug: true,
    };

    neuralNetwork = ml5.neuralNetwork(nnOptions, modelReady);
}

function modelReady() {
    neuralNetwork.normalizeData();
    neuralNetwork.train({ epochs: 50 }, whileTraining, finishedTraining);
}

// this doesn't get called at all
function whileTraining(epoch, logs) {
    console.log(`Epoch: ${epoch} - loss: ${logs.loss.toFixed(2)}`);
}

// this gets called immediately
function finishedTraining() {
    console.log("done!");
}

start()

控制台立即显示“完成!”,但模型没有经过训练。没有错误信息。 奇怪的是,当标签名称不正确时,我确实会收到错误消息。所以标签名称实际上是可以识别的。

原始 CSV 文件,正在运行:

survived,fare_class,sex,age,fare
died,first,male,39,0
died,first,male,29,0

我的 CSV 文件,不工作:

Survived,Pclass,Sex,Age,SibSp,Parch,Fare,Embarked
0,3,1,22.0,1,0,7.25,1
1,1,0,38.0,1,0,71.2833,2

【问题讨论】:

    标签: javascript machine-learning ml5 ml5.js


    【解决方案1】:

    以防万一有人遇到这个问题:当你分类时,标签总是必须是一个字符串......

    工作 CSV 文件:

    Survived,Pclass,Sex,Age,SibSp,Parch,Fare,Embarked
    yes,3,1,22.0,1,0,7.25,1
    no,1,0,38.0,1,0,71.2833,2
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-15
      • 2011-04-07
      • 1970-01-01
      • 1970-01-01
      • 2017-11-27
      • 2012-04-02
      • 2018-08-19
      • 2010-11-20
      相关资源
      最近更新 更多