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.

231 questions
369
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,845
  • 3
  • 13
  • 6
46
votes
5 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
  • 2,021
  • 3
  • 25
  • 43
36
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…
33
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 …
19
votes
2 answers

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
  • 397
  • 2
  • 10
14
votes
2 answers

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
  • 1,027
  • 2
  • 10
  • 26
11
votes
3 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
  • 659
  • 1
  • 8
  • 20
10
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,564
  • 2
  • 17
  • 38
9
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…
8
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
  • 519
  • 1
  • 6
  • 15
7
votes
1 answer

batch_size in tf model.fit() vs. batch_size in tf.data.Dataset

I have a large dataset that can fit in host memory. However, when I use tf.keras to train the model, it yields GPU out-of-memory problem. Then I look into tf.data.Dataset and want to use its batch() method to batch the training dataset so that it…
David293836
  • 1,165
  • 2
  • 18
  • 36
7
votes
2 answers

How to efficiently assign to a slice of a tensor in TensorFlow

I want to assign some values to slices of an input tensor in one of my model in TensorFlow 2.x (I am using 2.2 but ready to accept a solution for 2.1). A non-working template of what I am trying to do is: import tensorflow as tf from…
Zaccharie Ramzi
  • 2,106
  • 1
  • 18
  • 37
7
votes
2 answers

Install Tensorflow 2.x only for CPU using PIP

how do you install only a CPU version of Tensorflow 2.x using pip ? In the past, it was possible to install this 2 different versions. Since I am running the scripts in a nonen GPU device ( without envidia card, intel card available without cuda…
Mono Brezel
  • 133
  • 1
  • 2
  • 6
7
votes
1 answer

TensorFlow fit gives TypeError: Cannot clone object error

I am using a basic CNN model to classify my data. The dimensions of my input data is (325, 20, 244,244). The code that i have used is as follows: model = Sequential() model.add(Dense(2, activation='relu',…
Jheel Gopani
  • 71
  • 1
  • 2
7
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
  • 2,531
  • 1
  • 19
  • 34
1
2 3
15 16