Questions tagged [eager-execution]

TensorFlow's eager execution is an imperative programming environment that evaluates operations immediately, without building graphs: operations return concrete values instead of constructing a computational graph to run later. This makes it easy to get started with TensorFlow and debug models, and it reduces boilerplate as well. To follow along with this guide, run the code samples below in an interactive python interpreter.

146 questions
86
votes
3 answers

What is the purpose of the Tensorflow Gradient Tape?

I watched the Tensorflow Developer's summit video on Eager Execution in Tensorflow, and the presenter gave an introduction to "Gradient Tape." Now I understand that Gradient Tape tracks the automatic differentiation that occurs in a TF model. I was…
krishnab
  • 9,270
  • 12
  • 66
  • 123
34
votes
2 answers

InvalidArgumentError: cannot compute MatMul as input #0(zero-based) was expected to be a float tensor but is a double tensor [Op:MatMul]

Can somebody explain, how does TensorFlow's eager mode work? I am trying to build a simple regression as follows: import tensorflow as tf import numpy as np tfe = tf.contrib.eager tf.enable_eager_execution() def make_model(): net =…
Ankish Bansal
  • 1,827
  • 3
  • 15
  • 25
18
votes
3 answers

Inputs to eager execution function cannot be Keras symbolic tensors

I am trying to implement sample- and pixel-dependent dependent loss weighting in tf.Keras (TensorFlow 2.0.0rc0) for a 3-D U-Net with sparse annotation data (Cicek 2016, arxiv:1606.06650). This is my code: import numpy as np import tensorflow as…
bers
  • 4,817
  • 2
  • 40
  • 59
11
votes
1 answer

Using Tensorflow 2.0 and eager execution without Keras

So this question might stem from a lack of knowledge about tensorflow. But I am trying to build a multilayer perceptron with tensorflow 2.0, but without Keras. The reason being that it is a requirement for my machine learning course that we do not…
11
votes
2 answers

Tensorflow Eager Execution - Compute gradient between two layers of a sequential model

I am trying to follow along with the guide at http://www.hackevolve.com/where-cnn-is-looking-grad-cam/, using Tensorflow's new eager execution mode. One line in particular has me stumped: grads = K.gradients(class_output,…
AniSkywalker
  • 449
  • 5
  • 20
11
votes
2 answers

Hot to fix Tensorflow model not running in Eager mode with .fit()?

I'm trying to run a basic CNN keras model in Eager Execution but Tensorflow refuses to treat the model as eager. I originally attempted this in stable 1.13 branch (latest), making sure to enable eager execution with no result. I upgraded to 2.0…
ryan651
  • 121
  • 1
  • 1
  • 3
9
votes
1 answer

Why does model.losses return regularization losses?

I have met a snippet of code of tensorflow 2.0, which is used for calculating the loss. The total loss is composed of two parts: 1) regularization loss, 2) prediction loss. My question is why model.losses is regularization loss? model here is an…
zihaozhihao
  • 4,197
  • 2
  • 15
  • 25
8
votes
1 answer

What is the way to use Tensor flow 2.0 object in open cv2 python and why is it so circuitous?

I load an image using tensor flow api (2.0) like so : def load(image_file): image = tf.io.read_file(image_file) image = tf.image.decode_jpeg(image) Now that I have this object, I want to show this image, I can simply use matplotlib.pyplot, and…
6
votes
1 answer

What is tracing with regard to tf.function

The word "tracing" is mentioned frequently in TensorFlow's guide like Better performance with tf.function What is "tracing" exactly, does it refer to generating the graph as a result of calling the tf.function for the first time (and…
Jake Wu
  • 499
  • 4
  • 8
6
votes
2 answers

Run into the following issue: build_tensor_flow is not supported in Eager Mode

I am playing around with TensorFlow, and I am trying to export a Keras Model as a TensorFlow Model. And I ran into the above-mentioned error. I am following the "Build Deep Learning Applications with Keras 2.0" from Lynda…
6
votes
1 answer

Tensorflow 2 eager execution disabled inside a custom layer

I'm using TF2 installed via pip in a ubuntu 18.04 box $ pip freeze | grep "tensorflow" tensorflow==2.0.0 tensorflow-estimator==2.0.1 And I'm playing with a custom layer. import tensorflow as tf from tensorflow.keras.preprocessing import…
Kleyson Rios
  • 2,597
  • 5
  • 40
  • 65
6
votes
1 answer

TensorFlow: How can I inspect gradients and weights in eager execution?

I am using TensorFlow 1.12 in eager execution, and I want to inspect the values of my gradients and my weights at different points during training for debugging purposes. This answer uses TensorBoard to get nice graphs of weight and gradient…
user4028648
6
votes
1 answer

How to debug Keras in TensorFlow 2.0?

Actually, I find the problem already in TensorFlow 1.13.0. (tensorflow1.12.0 works well). My code is listed as a simple example: def Lambda layer(temp): print(temp) return temp which is used as a lambda layer in my Keras model. In…
LinTIna
  • 481
  • 1
  • 6
  • 14
6
votes
2 answers

Is it ok to call `tape.watch(x)` when `x` is already a `tf.Variable` in TensorFlow?

Consider the following function def foo(x): with tf.GradientTape() as tape: tape.watch(x) y = x**2 + x + 4 return tape.gradient(y, x) The call to tape.watch(x) is necessary if the function is called say as foo(tf.constant(3.14)), but…
Jakub Arnold
  • 85,596
  • 89
  • 230
  • 327
4
votes
1 answer

In Rust `map_or` and `map_or_else` method of `Option`/`Result`, what's lazy/eager evaluation?

I know Rust iterator (adaptors) are "lazy" since they doesn't actually do anything until we access them. To me iterators are like some sort of telescopes to peek stars, and that iterator adaptors are like adding more filters to make the telescope…
1
2 3
9 10