tensorflow.js

Recreate Tensor From String

依然范特西╮ 提交于 2020-01-04 07:48:17
问题 I am using tensorflow.js(node) as a way of preprocessing image files to tensors. const tf = require('@tensorflow/tfjs'); require("@tensorflow/tfjs-node") const mobilenetModule = require('@tensorflow-models/mobilenet'); const knnClassifier = require('@tensorflow-models/knn-classifier'); const { loadImage, createCanvas } = require('canvas') When I create a classifier, it saves a Tensor class object as a key:value pair. After creating this object, I stringify it, and write it to a file so I can

Getting weights from tensorflow.js neural network

社会主义新天地 提交于 2020-01-02 17:32:00
问题 I have this sequential model: this.model = tf.sequential() this.model.add(tf.layers.dense({units : 16, useBias : true, inputDim : 7})) // input this.model.add(tf.layers.dense({units : 16, useBias : true, activation: 'sigmoid'})) // hidden this.model.add(tf.layers.dense({units : 3, useBias : true, activation: 'sigmoid'})) // hidden 2 I checked API for tensorflow.js, but there's nothing about getting weights(kernels) of neural network. So, how can I get weights and then change them, to apply

Getting weights from tensorflow.js neural network

Deadly 提交于 2020-01-02 17:31:18
问题 I have this sequential model: this.model = tf.sequential() this.model.add(tf.layers.dense({units : 16, useBias : true, inputDim : 7})) // input this.model.add(tf.layers.dense({units : 16, useBias : true, activation: 'sigmoid'})) // hidden this.model.add(tf.layers.dense({units : 3, useBias : true, activation: 'sigmoid'})) // hidden 2 I checked API for tensorflow.js, but there's nothing about getting weights(kernels) of neural network. So, how can I get weights and then change them, to apply

Distinguish types of on-disk models

你。 提交于 2019-12-31 04:39:10
问题 Tensorflow has several types of model formats: TensorFlow SavedModel 2. Frozen Model 3. Session Bundle 4. Tensorflow Hub module How can you distinguish between them on-disk? (to later use with tensorflowjs-converter) And how is each model created? 回答1: Yup, there are a LOT of different model types, and they all have good reasons. I'm not going to claim that I have perfect clarity of each, but here's what I know (I think I know). The .pb file: PB stands for protobuff or Protocol Buffer. This

Tensorflow.js inputShape doesn't match model input

霸气de小男生 提交于 2019-12-31 04:08:09
问题 This seems to be pretty basic but I can't figure it out. So I have sample/data/inputs that is an array of arrays of 10 ints and the output/label it's just an array of integers. Let me explain as it might be that my data is not properly structured. Based on the input of 10 integers I tell the model the result is the 1 integer in the label/output. On top of that I cannot batch the data because they are sequential. Meaning the inputs shift by one to the right so the first nine integers in sample

Difference between tfjs_layers_model and tfjs_graph_model

折月煮酒 提交于 2019-12-25 01:43:38
问题 The tensorflowjs converter has the output formats tfjs_layers_model , tfjs_graph_model What is the difference between the two? Is there a use recommendation? 回答1: There seem to be only certain pairs of input and output formats that work, namely `keras` | `tfjs_layers_model` `keras_saved_model` | `tfjs_layers_model` `tf_hub` | `tfjs_graph_model` `tf_saved_model` | `tfjs_graph_model` 来源: https://stackoverflow.com/questions/55829043/difference-between-tfjs-layers-model-and-tfjs-graph-model

Extracting keypoints from posenet to a json file?

不羁的心 提交于 2019-12-24 20:31:03
问题 I am looking into the tensorflow implementation of posenet to do pose estimation in real time and also if possible in an offline mode. I am looking into the following repo : https://github.com/tensorflow/tfjs-models/tree/master/posenet The keypoints are read out in the following function in the following section of code export function drawKeypoints(keypoints, minConfidence, ctx, scale = 1) { for (let i = 0; i < keypoints.length; i++) { const keypoint = keypoints[i]; if (keypoint.score <

How to protect (obfuscate/DRM) trained model weights in Tensorflow.js?

懵懂的女人 提交于 2019-12-24 19:06:05
问题 I am working on a React-based web app that uses Tensorflow.js to run an AI model in realtime on the client in the browser. I've trained this AI model from scratch and I'd like to protect it from being intercepted and used in other projects. Are there any protections available to do this (obfuscation, DRM, etc.)? From a business perspective, I'd only like the model to work on my web app, nowhere else. The discussions (1 2 3) I've been able to find on this are more geared toward native apps,

Simple linear regression with TensorFlowJS

♀尐吖头ヾ 提交于 2019-12-24 18:11:05
问题 I'm trying to get some linear regression for a project. As I'm used to Javascript, I decided to try and use TensorFlowJS. I'm following the tutorial from their website and have watched some videos explaining how it works, but I still can't understand why my algorithm doesn't return the result I expect. Here is what I'm doing: // Define a model for linear regression. const model = tf.sequential(); model.add(tf.layers.dense({units: 1, inputShape: [1]})); // Prepare the model for training:

Simple linear regression with TensorFlowJS

橙三吉。 提交于 2019-12-24 18:10:06
问题 I'm trying to get some linear regression for a project. As I'm used to Javascript, I decided to try and use TensorFlowJS. I'm following the tutorial from their website and have watched some videos explaining how it works, but I still can't understand why my algorithm doesn't return the result I expect. Here is what I'm doing: // Define a model for linear regression. const model = tf.sequential(); model.add(tf.layers.dense({units: 1, inputShape: [1]})); // Prepare the model for training: