Alternative to 'tensorflow.contrib' with tensorflow=2.0.0

Viewed 1681

I am using TensorFlow version=2.0.0, python version=3.7.9 and I was trying to import the following:

import tensorflow.contrib.layers as layers

I get this error:

Exception has occurred: ModuleNotFoundError
No module named 'tensorflow.contrib'

As I read in this thread, tensorflow.contrib doesn't exist in 2.0. Does anyone know an alternative to it? I am trying to upgrade my code from 1.0 to 2.0 as I don't want to use tf 1.0. I am using this package to build up a RNN cell.

1 Answers

tf.contrib is deprecated in Tensorflow 2.x.

Replace import tensorflow.contrib.layers as layers

with

from tensorflow.keras.layers import RNN
Related