简体   繁体   English

有没有办法让 tensorflow js 从 json 文件而不是 csv 读取/训练数据?

[英]is there a way to make tensorflow js read/train data from a json file instead of a csv?

So I'm new with machine learning and have been struggling with making my model train from the data provided from a json file.所以我是机器学习的新手,并且一直在努力根据 json 文件提供的数据制作我的 model 火车。 I have no problem training with a csv.我用 csv 训练没有问题。 Also converting the json to csv is not an option since the json file is not simple.此外,将 json 转换为 csv 也不是一个选项,因为 json 文件并不简单。

Currently, tensorflow.js does not offer a way to load json data for training.目前,tensorflow.js 不提供加载 json 数据进行训练的方法。 So the options there are所以有选项

  • Use a json to csv converter使用 json 到 csv 转换器

That way tf.data.csv can be used to read the file这样tf.data.csv可以用来读取文件

  • Use a custom loader使用自定义加载器

First one needs to get the data using the fetch API for instance.例如,第一个需要使用 fetch API 获取数据。 Then, the dataset needs to be constructed with the data returned.然后,需要使用返回的数据构建数据集。 When the data is large, everythings needs not to be loaded in memory at the same time.当数据量大时,memory中不需要同时加载所有东西。 This answer discusses how to handle that case.这个答案讨论了如何处理这种情况。

Try to avoid doing the conversion on your own;尽量避免自己进行转换; use the Javascript JSON library for functions like JSON.parse and JSON.stringify that go recursively deep in an array and turn it into a Javascript-subscriptable object. use the Javascript JSON library for functions like JSON.parse and JSON.stringify that go recursively deep in an array and turn it into a Javascript-subscriptable object.

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

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