tensorflow.js

Tensorflow.js loading model returns function predict is not defined

五迷三道 提交于 2019-12-11 05:43:47
问题 When I load a saved model like this (please dont mind the fact that the predict function has no input) const tf = require('@tensorflow/tfjs'); require('@tensorflow/tfjs-node'); const model = tf.loadModel('file://./model-1a/model.json').then(() => { model.predict(); }); I get this error: (node:25887) UnhandledPromiseRejectionWarning: TypeError: model.predict is not a function at tf.loadModel.then (/home/ubuntu/workspace/server.js:10:9) at But when I just create a model instead of loading it

Loading saved_model causes “Failed to compile fragment shader” for gather op

我是研究僧i 提交于 2019-12-11 04:51:56
问题 I'm using Tensorflow in Python to define and train the model, and then I save it to a saved_model and load it on a website using TensorflowJS. I've made a minimal working example presented below, and have isolated the issue to the gather op. I'm using Windows 7 x64, Python 3.5.2, numpy 1.15.1 (forced upon installing tensorflowjs - had 15.2 before that) and the latest version of tensorflowjs installed using simply pip install tensorflowjs . The browser is Chrome, and it's all served on

Best practice to save a TensorflowJS model to firebase storage?

北慕城南 提交于 2019-12-11 03:34:54
问题 Seems possible to do a "post" http request based save. https://www.tensorflow.org/js/guide/save_load https://firebase.google.com/docs/functions/http-events Worried that I may be overcomplicating this, is there a simple way to perhaps create the json files in the client side js (maybe avoiding saving into local storage as well?), then simply upload to storage using put function? https://firebase.google.com/docs/storage/web/upload-files Not very experienced in these areas and could not find

How to use tfjs-node with libtensorflow that is built from source

假如想象 提交于 2019-12-11 01:08:55
问题 I see that it is possible to use libtensorflow that is built from source, as mentioned in the README https://github.com/tensorflow/tfjs-node#optional-build-libtensorflow-from-tensorflow-source I have successfully built from source, but I don't know how to let tfjs-node use this custom built version, instead of the pre-built one. 回答1: I found that the following workaround seems to work: Copy the file bazel-bin/tensorflow/libtensorflow.so from the tensorflow source directory to replace node

TensorFlow.js returning TypeError: Cannot read property 'concat' of undefined when loading models

白昼怎懂夜的黑 提交于 2019-12-10 12:04:58
问题 Trying to recreate the emoji scavenger hunt from google and it returned me the following error: Here is my only code that is running at the moment: import * as tf from '@tensorflow/tfjs'; import { loadFrozenModel, FrozenModel } from '@tensorflow/tfjs-converter'; export default class MobileNet { constructor() { } async load() { const MODEL_URL = '/assets/project-gaea/models/web_model.pb'; const WEIGHTS_URL = '/assets/project-gaea/models/weights_manifest.json'; const model = await

loadFrozenModel does not work with local files

只愿长相守 提交于 2019-12-10 11:34:15
问题 need help with async/await. currently studying https://github.com/tensorflow/tfjs-converter. and I'm stumped at this part of the code (loading my python converted saved js model for use in the browser): import * as tf from '@tensorflow/tfjs'; import {loadFrozenModel} from '@tensorflow/tfjs-converter'; /*1st model loader*/ const MODEL_URL = './model/web_model.pb'; const WEIGHTS_URL = '.model/weights_manifest.json'; const model = await loadFrozenModel(MODEL_URL, WEIGHTS_URL); /*2nd model

TensorFlowJS Exception - Cannot start training because another fit() call is ongoing

三世轮回 提交于 2019-12-10 10:23:58
问题 I used tf.expandDims() to add dimensions. Since I'm able to go into model.fit(), but got stuck due to this error Cannot start training because another fit() call is ongoing. and Cannot read property 'length' of undefined. You can find my code here // Train the model using the data. let tesnor_dim =[]; let tensr;for(var j=0; j<2; j++){ console.log('resize_image',resize_image); tensr = tf.expandDims(ysarr[j], 0); tesnor_dim.push(tensr); console.log('tesnor_dim',tesnor_dim); model.fit(resize

Computing the gradient of the loss using Tensorflow.js

不羁岁月 提交于 2019-12-08 01:04:34
问题 I am trying to compute the gradient of a loss, with relation to a network's trainable weights using Tensorflow.js in order to apply these gradients to my network's weight. In python, this is easily done using the tf.gradients() functions, which takes two minimum inputs representing dx and dy. However, I am not able to reproduce the behavior in Tensorflow.js. I am not sure wether my understanding of the gradient of the loss w.r.t the weights is wrong, or if my code contains mistakes. I have

What is the best way to handle large data with Tensorflow.js and tf.Tensor?

北城以北 提交于 2019-12-07 07:44:26
问题 Question I am using tf.Tensor and tf.concat() to handle large training data, and I found continuous using of tf.concat() gets slow. What is the best way to load large data from file to tf.Tensor ? Background I think it's common way to handle data by array in Javascript. to achieve that, here is the rough steps to go. steps to load data from file to Array read line from file parse line to Javascript's Object add that object to array by Array.push() after finish reading line to end, we can use

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