Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow.js with react-native

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

like image 299
tai C Avatar asked Apr 14 '18 02:04

tai C


1 Answers

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.

like image 196
tai C Avatar answered Sep 20 '22 02:09

tai C