tensorflow.js

Getting the result into a variable

陌路散爱 提交于 2019-12-20 02:00:12
问题 I have the following example code. I'm able to see the correct result in the console from the print function. // Define a model for linear regression. const model = tf.sequential(); model.add(tf.layers.dense({units: 1, inputShape: [1]})); model.add(tf.layers.dense({units: 4, inputShape: [1]})); model.add(tf.layers.dense({units: 10, inputShape: [1]})); model.add(tf.layers.dense({units: 1, inputShape: [1]})); // Prepare the model for training: Specify the loss and the optimizer. model.compile(

partition or mask or filter a Tensor in tensorflow.js

我怕爱的太早我们不能终老 提交于 2019-12-14 00:40:59
问题 I have 2 Tensors of same length, data and groupIds . I want to split data into several groups by the corresponding values in groupId . For example, const data = tf.tensor([1,2,3,4,5]); const groupIds = tf.tensor([0,1,1,0,0]); // expected result: [tf.tensor([1,4,5]), tf.tensor([2,3])] In Tensorflow there is tf.dynamic_partition which does exactly that. Tensorflow.js doesn't seem to have a similar method. I also looked into mask or filtering as work-arounds, but they don't exist either. Does

Expected dense_Dense1_input to have shape “a” but got array with shape “b”

匆匆过客 提交于 2019-12-13 18:42:29
问题 Anyone would help me with this TensorFlow JS project ? It's a Chat bot with machine learn, I stuck on 'build neural network' , giveme this error Project Link : https://github.com/ran-j/ChatBotNodeJS The training code at /routes/index.js line 189 //Build neural network model = tf.sequential(); model.add(tf.layers.dense({inputShape: [documents.length], units: 100})); model.add(tf.layers.dense({units: 4})); model.compile({loss: 'categoricalCrossentropy', optimizer: 'sgd'}); model.fit(xs, ys,

How can I load/retrain/save ssd_inception_v2_coco on tensorflow.js?

梦想的初衷 提交于 2019-12-12 19:32:41
问题 ML / Tensorflow beginner. Can any of these already-trained models be loaded on tfjs and re-trained there, then exported to Downloads or is Tensorflow python the only way to go? I see this process is well described and documented in this tutorial for Tensorflow Python but unfortunately I can't find any documentation/tutorial to re-train an object detection model on the browser with tfjs (image classification yes, object detection no). I see how I could load the coco-ssd model using npm, then

tensorflow.js in webworkers

时间秒杀一切 提交于 2019-12-12 19:11:45
问题 I want to import 2 scripts in webWorker by importScripts() as follows,but it failed to import. How to deal with it? self.importScripts('https://cdn.jsdelivr.net/npm/@tensorflow/tfjs'); self.importScripts('https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-converter'); error figure 回答1: Currently, it is not possible to use the webgl implementation on web-worker, the offlineCanvas being an experimental features. However, it is possible to use the CPU backend. Here is an example of delegation to the

Convert output of retrain.py to tensorflow.js

匆匆过客 提交于 2019-12-12 16:05:49
问题 The script retrain.py described in How to Retrain an Image Classifier for New Categories was run as python retrain.py --tfhub_module https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/2 --image_dir /tmp/test and produced the output file /tmp/output_graph.pb . Converting this with tensorflowjs_converter --input_format=tf_saved_model --output_format=tfjs_graph_model /tmp/output_graph.pb /tmp/model failed with IOError: SavedModel file does not exist at: /tmp/output_graph.pb/

Error converting keras model to tfjs: duplicate weight name Variable

荒凉一梦 提交于 2019-12-11 18:29:00
问题 Follwing the tutorial at https://www.tensorflow.org/tutorials/images/hub_with_keras resulted in a file model.h5 . Converting to tensorflow-js with the command tensorflowjs_converter --input_format keras ./model.h5 /tmp/jsmodel/ failed with Exception: Error dumping weights, duplicate weight name Variable Why is this and how can it be fixed? MCVE from __future__ import absolute_import, division, print_function import tensorflow as tf import tensorflow_hub as hub from tensorflow.keras import

TensorFlow.js: Saving different model instances during training

你。 提交于 2019-12-11 18:28:01
问题 I'm runing TensorFlow.JS on NODE and I'd like to be able to save a model during the training process at a certain point. I tryed to just copy the actual model to a global variable but the JavaScript object is copied by reference and at the end the global variable has the same model than the last training epoch. I then used many different JavaScript methods to do a deep clone (including lodash deep clone), but I get errors on the copied model like functions that end up missing (like model

Loading of mobilenet v2 works, but pretrained mobilenet v2 fails

ⅰ亾dé卋堺 提交于 2019-12-11 11:59:03
问题 I retrain a mobilenet v2 modell using my own images and i can label new images with the output in python (https://www.tensorflow.org/hub/tutorials/image_retraining). Loading the file works, but during prediction it fails with (concole.log of Firefox and Chromium): The dict provided in model.execute(dict) has keys: [images] not part of model graph. I retrain a modell using the provided retrain.py python retrain.py --image_dir flower_photos/ --tfhub_module https://tfhub.dev/google/imagenet

How to implement get_tensor_by_name and predict in tensorflow.js

你说的曾经没有我的故事 提交于 2019-12-11 06:09:55
问题 I want to use Faster rcnn inception v2 to do object detection in tensorflow.js. But i can't find some method in tfjs like get_tensor_by_name and session run for prediction. In tensorflow (python), the code as the following: Define input and output node: # Definite input Tensors for detection_graph self.image_tensor = self.detection_graph.get_tensor_by_name('image_tensor:0') # Definite output Tensors for detection_graph self.detection_boxes = self.detection_graph.get_tensor_by_name('detection