一直说它期望 dense_Dense1_input 具有形状 [null,8] 但得到形状为 [8,1] 的数组

Keeps saying it expects dense_Dense1_input to have shape [null,8] but gets array with shape [8,1]

我正在尝试使用 tensorflow.js 将我的 CSV 文件中的数据用于我的神经网络,但没有结果。相同的错误消息(检查时出错:预期 dense_Dense1_input 具有形状 [null,8] 但得到形状为 [8,1]. 的数组)不断弹出。我知道有人问过类似的问题,但我找不到任何将数据存储在 CSV 文件中的问题。

代码如下:

const dataLine = tf.tensor([0.352941,0.482412,0,0,0,0.353204,0.047822,0.116667]);

columnConfigs = {outcome: {isLabel: true}};
const dataset = tf.data.csv('data.csv', {columnConfigs}).map(({xs, ys}) => {return {xs:Object.values(xs), ys:Object.values(ys)}});

const model = tf.sequential();
model.add(tf.layers.dense({units: 12, inputShape: [8]}));
model.add(tf.layers.dense({units: 1, inputShape: [12]}));

model.compile({loss: 'meanSquaredError', optimizer: 'sgd'});
model.fitDataset(dataset, {
    epochs: 100,
  });

const prediction = model.predict(dataLine);
prediction.print();

我还链接了一小部分我正在使用的数据:

pregnancies,glucose,blood_pressure,skin_thickness,insulin,BMI,diabetes_pedigree_function,age,outcome
0.058824,0.507538,0.409836,0.151515,0.042553,0.360656,0.191289,0.083333,0
0.294118,0.442211,0.540984,0.212121,0.027187,0.363636,0.112724,0.15,0
0.470588,0.884422,0.737705,0.343434,0.35461,0.502235,0.166097,0.616667,1
0.411765,0.753769,0.540984,0.424242,0.404255,0.517139,0.273271,0.35,0
0.058824,0.366834,0.409836,0.10101,0,0.342772,0.072588,0,0
0.411765,0.939698,0.557377,0.393939,0.359338,0.561848,0.075149,0.333333,1
0,0.502513,0.721311,0.606061,0.130024,0.697466,0.377455,0.166667,0
0,0.733668,0.672131,0,0,0.603577,0.727156,0.383333,0
0,0.527638,0.52459,0.414141,0.167849,0.61848,0.040564,0.016667,0
0.117647,0.422111,0,0,0,0,0.096499,0,0

如有任何帮助,我们将不胜感激,谢谢

尝试批处理数据集:

const dataset = tf.data.csv('data.csv', {columnConfigs})
    .map(({xs, ys}) => {return {xs:Object.values(xs), ys:Object.values(ys)}})
    .batch(100)

但是预测的时候再扩展维度:

const dataLine = tf.tensor([0.352941,0.482412,0,0,0,0.353204,0.047822,0.116667])
    .expandDims();

...

const prediction = model.predict(dataLine);