tensorflow

How to extract data/labels back from TensorFlow dataset

家住魔仙堡 提交于 2020-12-29 05:30:07
问题 there are plenty of examples how to create and use TensorFlow datasets, e.g. dataset = tf.data.Dataset.from_tensor_slices((images, labels)) My question is how to get back the data/labels from the TF dataset in numpy form? In other words want would be reverse operation of the line above, i.e. I have a TF dataset and want to get back images and labels from it. 回答1: Supposing our tf.data.Dataset is called train_dataset , with eager_execution on, you can retrieve images and labels like this: for

How to extract data/labels back from TensorFlow dataset

这一生的挚爱 提交于 2020-12-29 05:28:55
问题 there are plenty of examples how to create and use TensorFlow datasets, e.g. dataset = tf.data.Dataset.from_tensor_slices((images, labels)) My question is how to get back the data/labels from the TF dataset in numpy form? In other words want would be reverse operation of the line above, i.e. I have a TF dataset and want to get back images and labels from it. 回答1: Supposing our tf.data.Dataset is called train_dataset , with eager_execution on, you can retrieve images and labels like this: for

How to extract data/labels back from TensorFlow dataset

牧云@^-^@ 提交于 2020-12-29 05:28:24
问题 there are plenty of examples how to create and use TensorFlow datasets, e.g. dataset = tf.data.Dataset.from_tensor_slices((images, labels)) My question is how to get back the data/labels from the TF dataset in numpy form? In other words want would be reverse operation of the line above, i.e. I have a TF dataset and want to get back images and labels from it. 回答1: Supposing our tf.data.Dataset is called train_dataset , with eager_execution on, you can retrieve images and labels like this: for

Weights and Bias from Trained Meta Graph

不想你离开。 提交于 2020-12-29 04:41:59
问题 I have successfully exported a re-trained InceptionV3 NN as a TensorFlow meta graph. I have read this protobuf back into python successfully, but I am struggling to see a way to export each layers weight and bias values, which I am assuming is stored within the meta graph protobuf, for recreating the nn outside of TensorFlow. My workflow is as such: Retrain final layer for new categories Export meta graph tf.train.export_meta_graph(filename='model.meta') Build python pb2.py using Protoc and

Tensorflow numpy image reshape [grayscale images]

瘦欲@ 提交于 2020-12-29 04:31:07
问题 I am trying to execute the Tensorflow "object_detection_tutorial.py" in jupyter notebook, with my trained neural network data but it throws a ValueError. The file mentioned above is part of Sentdexs tensorflow tutorial for object detection on youtube. You can find it here: (https://www.youtube.com/watch?v=srPndLNMMpk&list=PLQVvvaa0QuDcNK5GeCQnxYnSSaar2tpku&index=6) My Images are of Size: 490x704. So that would result in an 344960-array. But it sais: ValueError: cannot reshape array of size

Tensorflow numpy image reshape [grayscale images]

风格不统一 提交于 2020-12-29 04:30:26
问题 I am trying to execute the Tensorflow "object_detection_tutorial.py" in jupyter notebook, with my trained neural network data but it throws a ValueError. The file mentioned above is part of Sentdexs tensorflow tutorial for object detection on youtube. You can find it here: (https://www.youtube.com/watch?v=srPndLNMMpk&list=PLQVvvaa0QuDcNK5GeCQnxYnSSaar2tpku&index=6) My Images are of Size: 490x704. So that would result in an 344960-array. But it sais: ValueError: cannot reshape array of size

Implement perceptual loss with pretrained VGG using keras

强颜欢笑 提交于 2020-12-29 04:23:18
问题 I am relatively new to DL and Keras. I am trying to implement perceptual loss using the pretrained VGG16 in Keras but have some troubles. I already found that question but I am still struggling :/ A short explanation of what my network should do: I have a CNN (subsequent called mainModel) that gets grayscale images as input (#TrainData, 512, 512, 1) and outputs grayscale images with the same size. The network should reduce artifacts in the images - but I think it is not that important for

How to train a model in nodejs (tensorflow.js)?

青春壹個敷衍的年華 提交于 2020-12-29 02:36:49
问题 I want to make a image classifier, but I don't know python. Tensorflow.js works with javascript, which I am familiar with. Can models be trained with it and what would be the steps to do so? Frankly I have no clue where to start. The only thing I figured out is how to load "mobilenet", which apparently is a set of pre-trained models, and classify images with it: const tf = require('@tensorflow/tfjs'), mobilenet = require('@tensorflow-models/mobilenet'), tfnode = require('@tensorflow/tfjs-node

How to train a model in nodejs (tensorflow.js)?

两盒软妹~` 提交于 2020-12-29 02:36:41
问题 I want to make a image classifier, but I don't know python. Tensorflow.js works with javascript, which I am familiar with. Can models be trained with it and what would be the steps to do so? Frankly I have no clue where to start. The only thing I figured out is how to load "mobilenet", which apparently is a set of pre-trained models, and classify images with it: const tf = require('@tensorflow/tfjs'), mobilenet = require('@tensorflow-models/mobilenet'), tfnode = require('@tensorflow/tfjs-node

Why is TF Keras inference way slower than Numpy operations?

隐身守侯 提交于 2020-12-28 16:30:32
问题 I'm working on a reinforcement learning model implemented with Keras and Tensorflow. I have to do frequent calls to model.predict() on single inputs. While testing inference on a simple pretrained model, I noticed that using Keras' model.predict is WAY slower than just using Numpy on stored weights. Why is it that slow and how can I accelerate it? Using pure Numpy is not viable for complex models. import timeit import numpy as np from tensorflow.python.keras.models import Sequential from