[英]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所以有选项
That way tf.data.csv
can be used to read the file这样tf.data.csv
可以用来读取文件
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.