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
1
vote
1 answer

Convert to numpy a tensor without eager mode

I am defining a custom layer as the last one of my network. Here I need to convert a tensor, the input one, into a numpy array to define a function on it. In particular, I want to define my last layer similarly to this: import tensorflow as tf def…
Dadeslam
  • 201
  • 1
  • 8
1
vote
1 answer

tf.random.normal() doesn't work as expected

I am new on Python and tensorflow. I am a little (or a lot) puzzled: tf.random.normal() doesn't seem to work as expected. tf.random.normal() is used to generate some data. I want to see the data are generated as expected by printing them on the…
Garry
  • 11
  • 2
1
vote
1 answer

Error when using run_eagerly=False in model.compile custom Keras Model in Tensorflow

I am developing a custom model in Tensorflow. I am trying to implement a Virtual Adversarial Training (VAT) model from https://arxiv.org/abs/1704.03976. The model makes use of both labeled and unlabeled data in its classification task. Therefore, in…
thijsvdp
  • 404
  • 3
  • 16
1
vote
1 answer

tf.compat.v1.disable_eager_execution() with tf.data.dateset

I am using tensorflow 2.2. I have two numpy arrays (features and labels) that I pass to tf.data.dataset.from_tensor_slices(): train_dataset = tf.data.Dataset.from_tensors(feature_train_slice,…
Yahya Nik
  • 85
  • 2
  • 10
1
vote
1 answer

Use Hamming Distance Loss Function with Tensorflow GradientTape: no gradients. Is it not differentiable?

I'm using Tensorflow 2.1 and Python 3, creating my custom training model following the tutorial "Tensorflow - Custom training: walkthrough". I'm trying to use Hamming Distance on my loss function: import tensorflow as tf import tensorflow_addons as…
VansFannel
  • 45,055
  • 107
  • 359
  • 626
1
vote
1 answer

TypeError: has type , but expected one of: (,)

I have been trying to run the code from this tutorial on tf.data. But I am getting this error when trying to execute it in vs code. TypeError: has type
1
vote
0 answers

Tensorflow tf.GradientTape().gradient returns none

I designed a function to calculate gradients from loss and model.trainable_variables with Tensorflow GardientTape. I used this function to perform split-learning, which means the model is devided and trained on a client up to a specific layer. The…
1
vote
0 answers

tf.estimator input_fn and eager mode

I tried to use numpy inside cnn_model.evaluate(), but it gave AttributeError: 'Tensor' object has no attribute 'numpy'. I used numpy to calculate accuracy and mean squared error using tf.keras.metrics.Accuracy() and…
1
vote
1 answer

Model not executing eagerly in tensorflow 2.0 with keras

from sklearn.model_selection import train_test_split from sklearn.metrics import mean_squared_error import statistics import keras import numpy as np import pandas as pd from keras.models import Sequential from keras.layers import Dense…
1
vote
1 answer

Tensorflow Looping over Sliced Assign to Variable in Eager Execution Mode

For some custom code, I need to run a for-loop to dynamically create a variable in Tensorflow 2 (with eager execution mode enabled). (In my custom code, the values I write to the variable will require gradients, so I want to track the computations…
1
vote
1 answer

How to update parameter at each epoch within an intermediate Layer between training runs ? (tensorflow eager execution)

I have a sequential keras model and there i have a custom Layer similar to the following example named 'CounterLayer'. I am using tensorflow 2.0 (eager execution) class CounterLayer(tf.keras.layers.Layer): def __init__(self,…
1
vote
0 answers

How to map words to vocabulary index in TF 2.0 without eager execution

I have a Keras model that trains find when eager mode is on (TF 2.1.0). One of my features is a string that I need to map to its corresponding vocabulary index. However, with eager execution disabled, I cannot find a neat way to do this. I was…
Milad Shahidi
  • 627
  • 7
  • 13
1
vote
0 answers

Tensorflow gradientTape gives different result when calculating the same gradient twice

I'm experimenting with TF 2.0. I want to record the gradient and weights norm across my NN. To do so I'm using the following code. def get_weights_norm(layer, optim_iters, log=False): """ Calculate norm of layer's weights and save it as…
1
vote
1 answer

Why there is AttributeError: module 'tensorflow.contrib.eager' has no attribute 'Variable' in TensorFlow 1.15?

I had run a neural style transfer notebook tutorial in Google Colab successfully around one month ago. However, this week I can't run the exact same notebook successfully, with the following error message: AttributeError: module…
bowo
  • 51
  • 8
1
vote
1 answer

How to use complex variables in TensorFlow eager mode?

In non-eager mode I can run this without issues: s = tf.complex(tf.Variable(1.0), tf.Variable(1.0)) train_op = tf.train.AdamOptimizer(0.01).minimize(tf.abs(s)) with tf.Session() as sess: sess.run(tf.global_variables_initializer()) for i in…
Ziofil
  • 1,815
  • 1
  • 20
  • 30