简体   繁体   English

如何使用csv文件训练tensorflow.js模型?

[英]How to train a tensorflow.js model using a csv file?

Is it possible to train a tensorflow.js model using the path to a csv file on my computer? 是否可以使用计算机上csv文件的路径训练tensorflow.js模型? thank you! 谢谢!

From the version 0.14.1 , You can read csv file using tf.data.csv . 从版本0.14.1开始 ,您可以使用tf.data.csv读取csv文件。 However the data should be sent by a server. 但是,数据应由服务器发送。

One can serve a local file using a server like http-server . 可以使用http-server之的服务器提供本地文件。

http-server -c1 --cors .

Or using python3 http-server 或者使用python3 http-server

python3 -m http.server .

Then you can read your csv file 然后您可以读取您的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

}

You can start here: https://js.tensorflow.org/api/0.14.1/#data.csv . 您可以从这里开始: https : //js.tensorflow.org/api/0.14.1/#data.csv Not sure if you can pull the csv from the local file storage though. 但是不确定是否可以从本地文件存储中提取csv。 But what have you tried? 但是你尝试了什么?

Come back when you have some work done!! 完成工作后再回来!!

You can also convert the data into a JSON file with an online converter. 您还可以使用在线转换器将数据转换为JSON文件。 It may be the easiest way. 这可能是最简单的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM