tensorflow

How to convert from Tensorflow.js (.json) model into Tensorflow (SavedModel) or Tensorflow Lite (.tflite) model?

我怕爱的太早我们不能终老 提交于 2021-01-28 12:16:22
问题 I have downloaded a pre-trained PoseNet model for Tensorflow.js (tfjs) from Google, so its a json file. However, I want to use it on Android, so I need the .tflite model. Although someone has 'ported' a similar model from tfjs to tflite here, I have no idea what model (there are many variants of PoseNet) they converted. I want to do the steps myself. Also, I don't want to run some arbitrary code someone uploaded into a file in stackOverflow: Caution: Be careful with untrusted code—TensorFlow

Is there a way to supress TensorFlow logging in C-API

喜夏-厌秋 提交于 2021-01-28 12:12:27
问题 I managed to run my SavedModel generated by Python using C-API. Now I want to suppress all the verbose from TensorFlow as below: 2020-07-17 13:44:45.358903: I tensorflow/cc/saved_model/reader.cc:31] Reading SavedModel from: /home/philgun/tf-C-API/my_model 2020-07-17 13:44:45.360075: I tensorflow/cc/saved_model/reader.cc:54] Reading meta graph with tags { serve } 2020-07-17 13:44:45.361381: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow

sess.run() and “.eval()” in tensorflow programming

ⅰ亾dé卋堺 提交于 2021-01-28 12:12:11
问题 In Tensorflow programming, can someone please tell what is the difference between ".eval()" and "sess.run()". What do each of them do and when to use them? 回答1: A session object encapsulates the environment in which Tensor objects are evaluated. If x is a tf.Tensor object, tf.Tensor.eval is shorthand for tf.Session.run , where sess is the current tf.get_default_session . You can make session the default as below x = tf.constant(5.0) y = tf.constant(6.0) z = x * y with tf.Session() as sess:

train on multiple devices

北战南征 提交于 2021-01-28 12:04:10
问题 I have know that TensorFlow offer Distributed Training API that can train on multiple devices such as multiple GPUs, CPUs, TPUs, or multiple computers ( workers) Follow this doc : https://www.tensorflow.org/tutorials/distribute/multi_worker_with_keras But I have a question is this any possible way to split the train using Data Parallelism to train across multiple machines ( include mobile devices and computer devices)? I would be really grateful if you have any tutorial/instruction. 回答1: As

Make prediction with Keras model using multiple CPUs

℡╲_俬逩灬. 提交于 2021-01-28 12:04:00
问题 I am trying to make predictions with a Keras model (using Tensorflow 2.0) using multiple CPUs. I have tried this: tf.config.threading.set_intra_op_parallelism_threads(4) tf.config.threading.set_inter_op_parallelism_threads(4) While not getting an error, I am not sure if this is the right approach. Can predictions be multithreaded? Many thanks 来源: https://stackoverflow.com/questions/58974483/make-prediction-with-keras-model-using-multiple-cpus

Slice a tensor using tensor indices

我只是一个虾纸丫 提交于 2021-01-28 11:52:27
问题 I have a tensor img in TF representing an image, whose shape is (n_channels, img_height, img_width) . I also have a couple of integer tensors, h_start , h_end , w_start , w_end . I want to extract the part of the image that corresponds to what in numpy would be img[:, :, h_start:h_end, w_start:w_end] . How can I do that? 回答1: You can use tf.Tensor.__getitem__ pretty much like with NumPy indexing: img[:, h_start:h_end, w_start:w_end] Alternatively, use tf.slice: sliced_img = tf.slice(img, [0,

Tensorflow object detection API tutorial error

安稳与你 提交于 2021-01-28 11:48:49
问题 After struggling with compatibility issues between Tensorflow 2.00 and the object detection API, I downgraded to Tensorflow 1.15 to be able to train my own model. after completing the training I modified the jupyter notebook included in the Tensorflow object detection API repo to test on my own images but I keep getting this error: Traceback (most recent call last): File "object_detection_tutorial_converted.py", line 254, in <module> show_inference(detection_model, image_path) File "object

Change Hyperparameters on an ongoing simulation of TensorFlow

为君一笑 提交于 2021-01-28 11:22:21
问题 I wonder if it is possible to change some hyperparameters, let's say learning rate or regularization in real time during a TensorFlow simulation. Something like: You are monitoring the cost function of your neural net(NN) and then you decide that your NN could be doing better if you reduce the regularization term. But you would like to do this without interrupting everything. Just typing the new value in somewhere and then changing the regularization in the next epoch, for example. 回答1: You

Computing gradient of the model with modified weights

别等时光非礼了梦想. 提交于 2021-01-28 11:16:47
问题 I was implementing Sharpness Aware Minimization (SAM) using Tensorflow. The algorithm is simplified as follows Compute gradient using current weight W Compute ε according to the equation in the paper Compute gradient using the weights W + ε Update model using gradient from step 3 I have implement step 1 and 2 already, but having trouble implementing step 3 according to the code below def train_step(self, data, rho=0.05, p=2, q=2): if (1 / p) + (1 / q) != 1: raise tf.python.framework.errors

Tensorflow-GPU not using GPU with CUDA,CUDNN

不想你离开。 提交于 2021-01-28 11:15:11
问题 I want to use Tensorflow on GPU. So I install all the needed tool and installed as below- CUDA-11.2 CUDNN-11.1 Anaconda-2020.11 Tensorflow-GPU-2.3.0 I tested that my cuda,cudnn is working using deviseQuery example. But Tensorflow not used GPU. Then i find that version compatibility issue is possible so i innstalled CudaToolkit,cudnn using conda environment checking with version compatibility on Tensorflow website which is given below. CUDA-10.2.89 CUDNN-7.6.5 Tensorflow-GPU-2.3.0 But after