tensorflow.js

JS做深度学习2——导入训练模型

こ雲淡風輕ζ 提交于 2020-04-10 18:03:56
JS做深度学习2——导入训练模型 改进项目 前段时间,我做了个RNN预测金融数据的毕业设计(华尔街),当时TensorFlow.js还没有发布,我不得已使用了keras对数据进行了训练,并且拟合好了不同期货的模型,因为当时毕设的网站是用node.js写的,为了可以在网站中预测,我采取的方案是:用python进行训练和预测,然后使用node.js运行python命令,最终在浏览器上可视化出来,这也算的上是黑科技了! 不过这样通过一个解释器调用另一个解释器,语言之间互相通信其实不是什么好的设计方式,且不说维护两门语言的困难,调用其他语言过程会产生的错误和性能问题较多,而且显得整个项目很混乱,强迫症受不了。 如今,Google开始官推TensorFlow的JS API又是前端福音。但根据官网的介绍,TensorFlow.js目前尚不成熟,JS方面尚未实现像Python那么丰富的学习API。所以各种基于TF的深度学习项目如果需要使用JS重构也需要慢慢过渡。 更多关于TensorFlow.js的目前支持状况请参阅: https://www.linpx.com/p/you-want-to-know-that-everything-about-tensorflowjs-is-here.html 如上所述,TensorFlow.js尚不能导出训练文件,但可以导入训练文件,今天根据官网提供的文档

JS做深度学习2——导入训练模型

旧时模样 提交于 2020-04-10 17:19:08
JS做深度学习2——导入训练模型 改进项目 前段时间,我做了个RNN预测金融数据的毕业设计(华尔街),当时TensorFlow.js还没有发布,我不得已使用了keras对数据进行了训练,并且拟合好了不同期货的模型,因为当时毕设的网站是用node.js写的,为了可以在网站中预测,我采取的方案是:用python进行训练和预测,然后使用node.js运行python命令,最终在浏览器上可视化出来,这也算的上是黑科技了! 不过这样通过一个解释器调用另一个解释器,语言之间互相通信其实不是什么好的设计方式,且不说维护两门语言的困难,调用其他语言过程会产生的错误和性能问题较多,而且显得整个项目很混乱,强迫症受不了。 如今,Google开始官推TensorFlow的JS API又是前端福音。但根据官网的介绍,TensorFlow.js目前尚不成熟,JS方面尚未实现像Python那么丰富的学习API。所以各种基于TF的深度学习项目如果需要使用JS重构也需要慢慢过渡。 更多关于TensorFlow.js的目前支持状况请参阅: https://www.linpx.com/p/you-want-to-know-that-everything-about-tensorflowjs-is-here.html 如上所述,TensorFlow.js尚不能导出训练文件,但可以导入训练文件,今天根据官网提供的文档

Different predictions if running in Node instead of Browser (using the same model_web - python converted model)

删除回忆录丶 提交于 2020-03-04 18:56:18
问题 pretty new to ML and tensorflow! I made an object detection model with http://cloud.annotations.ai that permits to train and convert a model in different formats, tfjs (model_web) too. That website provides also boilerplates for running the model within a browser (react app)... just like you do - probably it is the same code, didn't spend enough time. So I have this model running inside a browser, giving prediction about objects in a photo with pretty good results considering the amount of

How to interpret the output of object detection model in tensorflow.js

大憨熊 提交于 2020-03-04 04:40:40
问题 I am trying to run custom object detection tensorflow.js model in a browser. I could able to convert tensorflow model to tensorflow.js model (in google colab) using the following command: !tensorflowjs_converter \ --input_format=tf_frozen_model \ --output_node_names='detection_boxes,detection_scores,detection_classes,num_detections' \ /content/frozen_inference_graph.pb \ /content/web_model I am sharing the code snippet of inference.html file: <html> <head> <script src="https://cdn.jsdelivr

How to interpret the output of object detection model in tensorflow.js

☆樱花仙子☆ 提交于 2020-03-04 04:40:11
问题 I am trying to run custom object detection tensorflow.js model in a browser. I could able to convert tensorflow model to tensorflow.js model (in google colab) using the following command: !tensorflowjs_converter \ --input_format=tf_frozen_model \ --output_node_names='detection_boxes,detection_scores,detection_classes,num_detections' \ /content/frozen_inference_graph.pb \ /content/web_model I am sharing the code snippet of inference.html file: <html> <head> <script src="https://cdn.jsdelivr

How may I define my own labels in tensorflow.js

谁说我不能喝 提交于 2020-02-25 07:17:06
问题 I have a three dimensional data say x,y,z of any sensor. I'm creating tensor of these values like tf.tensor3d([[[x1], [y1], [z1]], [[x2], [y2], [z3]], ....... so on]) . But I have just two labels that are not numeric values like [standing , sitting] . I want to assign a single label to the combination of three values of x,y,z . How may I train my model in tensorflow.js using my own labels ? 回答1: The first thing is to create an index of the label. ES2019 const labelArray = ["standing",

Tensorflow vs Tensorflow JS different results for floating point arithmetic computations

若如初见. 提交于 2020-02-25 02:02:10
问题 I have converted a Tensorflow model to Tensorflow JS and tried using in the browser. There are some preprocessing steps which are to be executed on the inout before feeding it to the model for inference. I have implemented these steps same as the Tensorflow. The problem is the inference results are not same on TF JS in comparison with Tensorflow. So I have started debugging the code and found that the results from the floating point arithmetic operations in the preprocessing on TF JS are

Importing TF model into TensorflowJS (trained in Python) fails: “Input 0 is incompatible with layer flatten: expected min_ndim=3, found ndim=2.”

亡梦爱人 提交于 2020-02-21 06:56:14
问题 Error in JS: Uncaught (in promise) Error: Input 0 is incompatible with layer flatten: expected min_ndim=3, found ndim=2. I have found threads for the same error from people trying to import pretrained models in keras/python (like VGG oder ResNets). For them it was mostly because of them still including the top layers of the model, so those threads unfortunately have nothing to do with my problem of fully importing a self-trained model from python in TensorflowJS. My code: Python code: model =

Importing TF model into TensorflowJS (trained in Python) fails: “Input 0 is incompatible with layer flatten: expected min_ndim=3, found ndim=2.”

妖精的绣舞 提交于 2020-02-21 06:54:07
问题 Error in JS: Uncaught (in promise) Error: Input 0 is incompatible with layer flatten: expected min_ndim=3, found ndim=2. I have found threads for the same error from people trying to import pretrained models in keras/python (like VGG oder ResNets). For them it was mostly because of them still including the top layers of the model, so those threads unfortunately have nothing to do with my problem of fully importing a self-trained model from python in TensorflowJS. My code: Python code: model =

Import Python Keras model with weights into Tensorflow.js

≡放荡痞女 提交于 2020-02-06 18:53:55
问题 I have some neural networks for the classification of images developed in Python 3.7 using the Keras package that is included in TensorFlow and I want to export the layers and weights model to import it in a Node.js application that uses Tensorflow.js. I have the neural networks saved in h5 format with two separate files, one for the layer model and the other for the weights model. Try to follow this tutorial that Tensorflow proposes (https://www.tensorflow.org/js/tutorials/conversion/import