AttributeError: module 'tensorflow._api.v2.train' has no attribute 'RMSPropOptimizer'

Issue

I am trying to run this code file using google colab. Although I am getting some of the outputs but an error is showing up

AttributeError: module 'tensorflow._api.v2.train' has no attribute 'RMSPropOptimizer'

I looked this problem up on stack overflow like most problems I face but there’s no solution. Someone, please help me understand what’s wrong with the code. I am completely new to TensorFlow.

NOTE: I would’ve pasted the whole code here but it’s a 1400+ line code so I directly hyperlinked the file as people might get annoyed and moreover, by doing so this post will get very long. But if needed, I can edit the post and paste the whole code here.

Solution

The correct name is RMSprop and its located under tf.keras.optimizers. Therefore, please replace

optimizer=tf.train.RMSPropOptimizer(1e-4)

with

optimizer=tf.keras.optimizers.RMSprop(1e-4)

TensorFlow version: v2.5.0

Sources and more info:

Answered By – Pouyan

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published