Kar*_*dan 3 javascript machine-learning tensorflow.js
是否可以使用计算机上 csv 文件的路径来训练 tensorflow.js 模型?谢谢你!
从0.14.1版本开始,您可以使用tf.data.csv读取 csv 文件。但是,数据应该由服务器发送。
可以使用像http-server这样的服务器来提供本地文件。
http-server -c1 --cors .
Run Code Online (Sandbox Code Playgroud)
或者使用 python3 http-server
python3 -m http.server .
Run Code Online (Sandbox Code Playgroud)
然后你可以读取你的csv文件
const csvUrl = 'localhost:port/file';
async function run() {
const csvDataset = tf.data.csv(
csvUrl, {
columnConfigs: {
medv: {
isLabel: true
}
}
});
// then you can use your dataset
}
Run Code Online (Sandbox Code Playgroud)