Tensorflow.js with react-native

两盒软妹~` 提交于 2019-12-07 02:13:43

问题


I am aware tensor-flow.js is a web focused lib, but out of curiosity i tried it on react-native as well, it sort of works. It only works on debug-mode, and throws an error when debug-mood is turn off, the error says window.location.search is not an object. after some research i found that the window object is created in debug mode, but when out of debug mode it do not exist.

my understanding of this if somehow we can work around it, tfjs can also work on react-native, kind of like d3, the math part of the library works well with react but not the dom/svg manipulation part. for tfjs all we need is the math part for it to run on our mobile device, correct me if i am wrong.

https://github.com/tangtai/tensorflowJs-rn here is the repo of the project i created, it predicts a linear model and predict with with hardcoded value.

img of the application runs

img of error

I think there will be lots of possibilities if tfjs can run on react-native


回答1:


The tensorflow-js team released an offical package for react-native

https://www.npmjs.com/package/@tensorflow/tfjs-react-native

if you want to run tensorflow on rn you should check it out.




回答2:


Is it possible to use tenserflow.js with react native?

The link above might be the answer for you.

I'm still curious on this subject anyway, because I also think this is possible technically.



来源:https://stackoverflow.com/questions/49827412/tensorflow-js-with-react-native

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!