Tensorflow 2.3.0 - Warning: get_next_as_optional (from tensorflow.python.data.ops.iterator_ops) is deprecated and will be removed in a future version

Viewed 1152

I've just updated to TF-2.3. In a model using tf.data.Dataset.from_tensor_slices as data source, I get the folowing warning:

WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/data/ops/multi_device_iterator_ops.py:601: get_next_as_optional (from tensorflow.python.data.ops.iterator_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.data.Iterator.get_next_as_optional()` instead.

I didn't find the instructions on the documentation on how to use the updated methods.

train_dataset = tf.data.Dataset.from_tensor_slices(
    (
        {"input_1": x1_train, 
         "input_2": x2_train}, 
        {"output": y_train},
    )
)

train_batches = train_dataset.batch(GLOBAL_BATCH_SIZE)

Training:

history = model.fit(
    x = train_batches,
    epochs=30,
    verbose = 1,
)

Thanks in advance.

1 Answers

You can ignore this warning in 2.3. This is here to let you know that one of the libraries you're using is calling a method that TensorFlow plans on removing in a future release. For your current usage it'll work fine.

Related