我正在尝试从CSV中加载任何适合模型的数据。这是(简化的)代码:
import { data, layers, sequential } from '@tensorflow/tfjs-node';
const dataset = data.csv('file://C:\\Users\\rgott\\Projects\\tensorflow-js-node\\data.csv', {
columnConfigs: {
PurchasePrice: {
isLabel: true,
dtype: 'float32',
},
LivingArea: {
dtype: 'float32',
required: true,
},
GardenArea: {
dtype: 'float32',
default: 0,
},
},
configuredColumnsOnly: true,
hasHeader: true,
delimiter: ',',
});
const model = sequential({
layers: [
layers.dense({inputShape: [2], units: 5, activation: 'relu'}),
layers.dense({units: 1, activation: 'softmax'}),
],
});
model.compile({optimizer: 'adam', loss: 'meanSquaredError'})
await model.fitDataset(dataset, {epochs: 10});
数据如下:
PurchasePrice,LivingArea,GardenArea,HasBalcony,HasElevator,HasTerrace,IncludedParkingSpots,Rooms,YearOfConstruction,FirstTimeUse
"178,695","35.5",,Yes,Yes,Yes,0,2,,Yes
"315,000",112,,No,No,No,0,,,No
"589,000","124.33","54.69",No,No,Yes,0,5,,Yes
"387,030","79.01",,Yes,Yes,Yes,0,3,,Yes
...
我遇到标题中提到的错误:
UnhandledPromiseRejectionWarning:错误:数据集生成的要素数据缺少必需的输入键'dense_Dense1_input'。
我已经搜索了Google和SO几个小时,但我不知道自己在做什么错。为什么要寻找某种输入名称?难道不就将Xs中的所有值都作为输入吗?
以防万一:
@tensorflow/tfjs-node
:2.1.0
ts-node
:8.10.2
typescript
:3.9.7