Questions tagged [tensorflow2.x]

The tag should be used for question exclusively related to TensorFlow >= 2.0 versions. There exist a couple of differences between TensorFlow2.X versions and TensorFlow1.X versions; therefore, it is natural that an exact tag distinction exists between those major version differences. Minor versions between TF 2.0(e.g. 2.0 vs 2.1) also bring code/framework differences; thus it will be incorrect to use the tensorflow2.0 tag at every question.

252 questions
312
votes
16 answers

How to prevent tensorflow from allocating the totality of a GPU memory?

I work in an environment in which computational resources are shared, i.e., we have a few server machines equipped with a few Nvidia Titan X GPUs each. For small to moderate size models, the 12 GB of the Titan X is usually enough for 2–3 people to…
Fabien C.
  • 3,275
  • 3
  • 11
  • 6
33
votes
2 answers

Custom TensorFlow Keras optimizer

Suppose I want to write a custom optimizer class that conforms to the tf.keras API (using TensorFlow version>=2.0). I am confused about the documented way to do this versus what's done in implementations. The documentation for…
30
votes
4 answers

Tensorboard not found as magic function in jupyter

I want to run tensorboard in jupyter using the latest tensorflow 2.0.0a0. With the tensorboard version 1.13.1, and python 3.6. using ... %tensorboard --logdir {logs_base_dir} I get the error : UsageError: Line magic function %tensorboard not…
Florida Man
  • 1,361
  • 1
  • 16
  • 29
19
votes
3 answers

Should I use @tf.function for all functions?

An official tutorial on @tf.function says: To get peak performance and to make your model deployable anywhere, use tf.function to make graphs out of your programs. Thanks to AutoGraph, a surprising amount of Python code just works with …
problemofficer
  • 1,502
  • 2
  • 16
  • 29
9
votes
1 answer

Input pipeline w/ keras.utils.Sequence object or tf.data.Dataset?

I am currently using a tf.keras.utils.Sequence object to generate image batches for a CNN. I am using Tensorflow 2.2 and the Model.fit method for the model. When I fit the model, the following warning is thrown in each epoch when I set…
Connor
  • 197
  • 1
  • 8
9
votes
2 answers

Get length of a dataset in Tensorflow

source_dataset = tf.data.TextLineDataset('primary.csv') target_dataset = tf.data.TextLineDataset('secondary.csv') dataset = tf.data.Dataset.zip((source_dataset, target_dataset)) dataset = dataset.shard(10000, 0) dataset = dataset.map(lambda source,…
Evan Weissburg
  • 1,690
  • 2
  • 11
  • 36
5
votes
0 answers

Unexplained RAM usage and potential memory leak when using tf.data.TFRecordDataset

Background We are relatively new to TensorFlow. We are working on a DL problem involving a video dataset. Due to the volume of data involved, we decided to preprocess the videos and store the frames as jpegs in TFRecord files. We then plan to use…
strider0160
  • 369
  • 3
  • 9
5
votes
1 answer

How to debug out of memory in tensorflow2-gpu

I am using tensorflow-2 gpu with tf.data.Dataset. Training on small models works. When training a bigger model, everything works at first : gpu is used, the first epoch works with no trouble (but I am using most of my gpu memory). At validation…
Wiwi
  • 115
  • 1
  • 5
5
votes
1 answer

Tensorflow 2.1.0 - An op outside of the function building code is being passed a "Graph" tensor

I am trying to implement a recent paper. Part of this implementation involves moving from tf 1.14 to tf 2.1.0. The code was working with tf 1.14 but is no longer working. NOTE: If I disable eager execution tf.compat.v1.disable_eager_execution()…
5
votes
1 answer

AttributeError: 'Tensor' object has no attribute 'numpy' in Tensorflow 2.1

I am trying to convert the shape property of a Tensor in Tensorflow 2.1 and I get this error: AttributeError: 'Tensor' object has no attribute 'numpy' I already checked that the output of tf.executing eagerly() is True, A bit of context: I load a…
Nick Skywalker
  • 673
  • 6
  • 18
5
votes
1 answer

shuffling two tensors in the same order

As above. I tried those to no avail: tf.random.shuffle( (a,b) ) tf.random.shuffle( zip(a,b) ) I used to concatenate them and do the shuffling, then unconcatenate / unpack. But now I'm in a situation where (a) is 4D rank tensor while (b) is 1D, so,…
Alex Deft
  • 1,460
  • 8
  • 19
5
votes
1 answer

What is the difference between keras.tokenize.text_to_sequences and word embeddings

Difference between tokenize.fit_on_text, tokenize.text_to_sequence and word embeddings? Tried to search on various platforms but didn't get a suitable answer.
4
votes
2 answers

AttributeError: module 'tensorflow_core.keras.layers.experimental.preprocessing' has no attribute 'RandomFlip'

I use Tensorflow 2.1.0 In this code data_augmentation = tf.keras.Sequential([ tf.keras.layers.experimental.preprocessing.RandomFlip('horizontal'), tf.keras.layers.experimental.preprocessing.RandomRotation(0.3) ]) I find this…
seni
  • 439
  • 1
  • 10
4
votes
0 answers

CUDA_ERROR_NOT_INITIALIZED by model.predict() using tensorflow2.3

I use efficient-net with tensorflow2.3 API (keras==2.4.3) https://www.tensorflow.org/api_docs/python/tf/keras/applications/efficientnet I could train and prediction on jupyterlab. On the other hand, while Flask implementation, model checkpoint could…
4
votes
0 answers

TensorFlowOpLayer messes up the TensorBoard graphs

This question is about TensorFlow (and TensorBoard) version 2.2rc3, but I have experienced the same issue with 2.1. It is a continuation of the question 'Messed up TensorBoard graphs due to Python operations'. Consider the following code: from…
Rani Pinchuk
  • 51
  • 1
  • 5
1
2 3
16 17