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.
Questions tagged [eager-execution]
146 questions
0
votes
1 answer
In Tensorflow how can I (1) compute gradients and (2) update variables in *separate* @tf.function methods?
I need to compute tf.Variable gradients in a class method, but use those gradients to update the variables at a later time, in a different method. I can do this when not using the @tf.function decorator, but I get the TypeError: An op outside of the…

mattroos
- 125
- 1
- 11
0
votes
2 answers
NotImplementedError: numpy() is only available when eager execution is enabled; while using TF2.4.1
Using tensorflow 2.4.1, I'm overriding SimpleRNNCell.call in keras, found here:
https://github.com/tensorflow/tensorflow/blob/85c8b2a817f95a3e979ecd1ed95bff1dc1335cff/tensorflow/python/keras/layers/recurrent.py#L1362
exactly the bias part as…

Ramy Hanna
- 13
- 1
- 5
0
votes
1 answer
Updating dictionary with tensorflow 2.1.0
I am facing a problem and I cannot seem to find the solution anywhere else, so I decided to post my question here (I have basic knowledge of tensorflow but quite new):
I wrote a simple code in python to illustrate what I want to do.
import…

MrBellamy
- 29
- 5
0
votes
0 answers
Eager Execution Error in TensorFlow for tf.GradientTape
I am getting this warning when I am trying to create saliency visualizations.
RuntimeError Traceback (most recent call last)
in ()
8 fig, axes = plt.subplots(1, 2)
9…

Shourya Verma
- 19
- 5
0
votes
1 answer
Batch element-wise product in loss function with keras
I am trying to write a custom loss function in keras where I need to weight the MSE between y_true and y_pred (shape: (batch_size, 64, 64)) by the output of an intermediate layer (whose shape is (batch_size, 1)).
The op I need is simply weight…

gisk
- 69
- 6
0
votes
1 answer
eager execution on tensorflow2.3.0
I'm doing a beginner course on TensorFlow. The version I have installed is 2.3.0. I have had problems with eager execution since the course's TensorFlow version is different from the one I have installed. Does anyone know how I can perform an eager…

Alex Delarge
- 29
- 5
0
votes
1 answer
How do I fine tune using eager few shot object detection on custom dataset with multiple classes which is in coco format?
I have been trying to use this eager few shot object detection tutorial. Instead of using the rubber ducky data, I wanted to use my custom dataset which is already in coco format and quite large. I tried to generate gt_boxes using my dataset but…

Achyut Sarma
- 119
- 7
0
votes
1 answer
when we should use tf.function decorator
I'm trying to boost the performance of a simple 2NN. Here is the code:
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras.optimizers import SGD
from tensorflow.keras.datasets import…

m b
- 61
- 6
0
votes
1 answer
How to define dynamic-shape variable when building computational graph with Tensorflow 1.15
System information
Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 18.04
Mobile device (e.g. iPhone 8, Pixel 2, Samsung…

lengoanhcat
- 43
- 2
0
votes
1 answer
Value of tensor operation does not update after depending variable updated/assigned in tensorflow 2.2, running in eager execution
I run the following code in tensorflow 2.2
a = tf.constant([2.0, 3.0, 4.0])
b = tf.Variable([4.0, 3.0, 5.0])
c = a * b
Value of b is:
Value of c…

palazzo train
- 3,229
- 1
- 19
- 40
0
votes
1 answer
How do you pass session object in TensorFlow v2?
I have a function change_weight() that modifies weights in any given model. This function resides in a different python file.
So if I have a simple neural network that classifies MNIST images, I test the accuracy before and after calling this…

nj2237
- 1,220
- 3
- 21
- 25
0
votes
1 answer
Why trainable_variables Do not Change after Training?
I went over
a basic example of tf2.0
containing very simple code
from __future__ import absolute_import, division, print_function, unicode_literals
import os
import tensorflow as tf
import cProfile
# Fetch and format the mnist…

Theron
- 567
- 1
- 7
- 21
0
votes
1 answer
Creating modified version of SparseCategoricalAccuracy, getting ValueError: tf.function-decorated function tried to create variables on non-first call
I'm trying to create a masked version of SparseCategoricalAccuracy in tf 2.0 that can be passed to the Keras api via compile(metrics=[masked_accuracy_fn()].
The function looks like:
def get_masked_acc_metric_fn(ignore_label=-1):
"""Gets the…

Feynman27
- 3,049
- 6
- 30
- 39
0
votes
1 answer
How to execute TensorFlow 2 Keras Sequential model in eager mode when "compile"?
I want to build a loss in a "pythonic" way using the eager execution of TF2, but even in eager mode, Keras is passing non-eager tensors.
Code:
def conditional_loss(self, y_true, y_pred):
print(y_true)
return 0
def…

flaviussn
- 1,305
- 2
- 15
- 33
0
votes
0 answers
Tensorflow graph execution ignores equality condition in earger execution mode
I stumbled on some weird tensorflow behaviour. After tf.print everywhere, it led me to the cause as shown in the following code but don't know why it happened unless either threading race condition or graph construction omitted the code segment.…

Kriss
- 21
- 3