我试图用ml5.js创建一个模型,并在控制台中看到一个错误:Error: Error when checking : expected dense_Dense1_input to have shape [null,250] but got array with shape [1,1].
使用此命令,您可以将所有项目文件复制到计算机以进行测试:
git clone https://github.com/anonym2048/mystuff.git
sketch.js
var options = {
task: "regression",
debug: true,
dataUrl: "germany_covid.csv",
inputs: ["Date"],
outputs: ["Cases"],
layers: [
{
type: 'dense',
units: 16,
inputShape: [250], //what should I put here?
activation: 'relu',
},
{
type: 'dense',
activation: 'sigmoid',
},
],
};
var nn = ml5.neuralNetwork(options, train);
function train() {
nn.normalizeData();
var trainingOptions = {
epochs: 256,
batchSize: 500,
};
nn.train(trainingOptions, predict);
}
function predict(){
nn.predict({"Date": "2020-10-20"}).then((result) => {
console.log(result);
});
}index.html
<html>
<head>
<meta charset="UTF-8" >
<title></title>
</head>
<body>
<script src="ml5.min.js" type="text/javascript"></script>
<script src="sketch.js"></script>
</body>
</html>csv文件:https://raw.githubusercontent.com/anonym2048/mystuff/main/germany_covid.csv
我希望它能在控制台中给我一个预测结果。
我试着使用对象的"inputShape“属性,但是当我将值从250个更改为1,1时,模型的训练就没有开始。
我怎样才能解决这个问题?
发布于 2020-10-16 08:38:59
问题是输入值必须是数字。我用了弦乐。
https://stackoverflow.com/questions/64382287
复制相似问题