tensorflow2.0

TF2: Compute gradients in keras callback in non-eager mode

纵然是瞬间 提交于 2020-07-09 06:58:07
问题 TF Version: 2.2.0-rc3 (in Colab) I am using the following code (from tf.keras get computed gradient during training) in a callback to compute gradients for all parameters in a model. def on_train_begin(self, logs=None): # Functions return weights of each layer self.layerweights = [] for lndx, l in enumerate(self.model.layers): if hasattr(l, 'kernel'): self.layerweights.append(l.kernel) input_tensors = [self.model.inputs[0], self.model.sample_weights[0], self.model.targets[0], K.learning_phase

How do i install tensorflow 2.2 in windows?

时光怂恿深爱的人放手 提交于 2020-07-08 02:56:11
问题 I have conda 4.8.3 and Python 3.7.4 on Windows 8.1. I have tf 2.0.0 installed in a conda environment. How do I upgrade to 2.2.x? Or, how do I just install 2.2.x in a conda environment? Edit 1: pip install --upgrade tensorflow says: Requirement already up-to-date: tensorflow in d:\anaconda3\envs\tf2\lib\site-packages (2.1.0) but tf version is still 2.0. Edit 2: conda install tensorflow==2.2.0 says: PackagesNotFoundError: The following packages are not available from current channels:

using one GradientTape with global context

孤人 提交于 2020-07-07 11:07:20
问题 I would like to use GradientTape to observe gradients during eager execution mode. Is it possible to create a GradientTape once, which then records everything, as if it had global context? Here is an example of what I would like to do: import numpy as np import tensorflow as tf x = tf.Variable(np.ones((2,))) y=2*x z=2*y tf.gradients(z, x) # RuntimeError, not supported in eager execution Now, this can be fixed easily: with tf.GradientTape() as g: y = 2*x z = 2*y g.gradient(y, x) # this works

How to accumulate gradients in tensorflow 2.0?

一世执手 提交于 2020-07-07 05:07:42
问题 I'm training a model with tensorflow 2.0 . The images in my training set are of different resolutions. The Model I've built can handle variable resolutions (conv layers followed by global averaging). My training set is very small and I want to use full training set in a single batch. Since my images are of different resolutions, I can't use model.fit() . So, I'm planning to pass each sample through the network individually, accumulate the errors/gradients and then apply one optimizer step. I

How to accumulate gradients in tensorflow 2.0?

孤街醉人 提交于 2020-07-07 05:07:36
问题 I'm training a model with tensorflow 2.0 . The images in my training set are of different resolutions. The Model I've built can handle variable resolutions (conv layers followed by global averaging). My training set is very small and I want to use full training set in a single batch. Since my images are of different resolutions, I can't use model.fit() . So, I'm planning to pass each sample through the network individually, accumulate the errors/gradients and then apply one optimizer step. I

Installing Tensorflow 2 gets a dll failed to load in pywrap_tensorflow.py

こ雲淡風輕ζ 提交于 2020-07-04 00:22:15
问题 I have had problems here, here and there installing tensorflow 2 over the last year or so. So I am trying miniconda. I have an amd radeon hd 6670 and an amd radeon hd 6450. I just downloaded miniconda and made an environment and did a pip install --upgrade tensorflow in an miniconda prompt on windows 8.1 and got tensorflow 2.2. When I try to import tensorflow I get the stack trace below. I did download visual studio to get the latest redistributebles (I think). seems like this occurs near

Installing Tensorflow 2 gets a dll failed to load in pywrap_tensorflow.py

喜夏-厌秋 提交于 2020-07-04 00:20:35
问题 I have had problems here, here and there installing tensorflow 2 over the last year or so. So I am trying miniconda. I have an amd radeon hd 6670 and an amd radeon hd 6450. I just downloaded miniconda and made an environment and did a pip install --upgrade tensorflow in an miniconda prompt on windows 8.1 and got tensorflow 2.2. When I try to import tensorflow I get the stack trace below. I did download visual studio to get the latest redistributebles (I think). seems like this occurs near

Installing Tensorflow 2 gets a dll failed to load in pywrap_tensorflow.py

放肆的年华 提交于 2020-07-04 00:20:20
问题 I have had problems here, here and there installing tensorflow 2 over the last year or so. So I am trying miniconda. I have an amd radeon hd 6670 and an amd radeon hd 6450. I just downloaded miniconda and made an environment and did a pip install --upgrade tensorflow in an miniconda prompt on windows 8.1 and got tensorflow 2.2. When I try to import tensorflow I get the stack trace below. I did download visual studio to get the latest redistributebles (I think). seems like this occurs near

How to print the detected classes after performing object detection on an image?

怎甘沉沦 提交于 2020-06-29 08:21:28
问题 I am following the object_detection_tutorial.ipynb tutorial. Here is the code ( I only put parts which are needed, the rest of the code is the same as the notebook): my_results = [] # I added this, a list to hold the detected classes PATH_TO_LABELS = 'D:\\TensorFlow\\models\\research\\object_detection\\data\\oid_v4_label_map.pbtxt' category_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS, use_display_name=True) PATH_TO_TEST_IMAGES_DIR = pathlib.Path('C:\\Users\

Failed to get device attribute 13 for device 0

耗尽温柔 提交于 2020-06-29 03:54:58
问题 When I'm trying to run Yolo detection examples, I got that error: 2020-02-02 21:39:00.821721: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll WARNING:tensorflow:From C:\Users\Dominux\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\ops\resource_variable_ops.py:1635: calling BaseResourceVariable.__init__ (from tensorflow.python.ops.resource_variable_ops) with constraint is deprecated and will be