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

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.

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:
TensorFlow docs
Keras example
GitHub issue comment
Similar question on StackOverflow

Related

An error in Alpyne library in a RL problem

I am new to RL and wanted to test some examples about it.
One of the examples is stock management problem and I wanted to run "rlpolicy_train.py" on google Colab.
The link for example:
https://github.com/t-wolfeadam/Alpyne/tree/main/examples/Stock%20Management%20Game
It seems that there is an error in Alpyne Library and I can't understand what is the meaning of this error and how I can fix it.
The screenshot of the error has been attached.
I would appreciate it if anyone can help.

"HTTPError: HTTP Error 404: Not Found" while using translation function in TextBlob

When I try to use translate function in TextBlob library in jupyter notebook, I get:
HTTPError: HTTP Error 404: Not Found
I have posted my code and screenshot of error message for reference here. This code worked well 5-6 days ago when I ran exactly the same code first time but after that whenever I run this code it gives me the same error message. I have been trying to run this code since last 4-5 days but it never worked again.
My code:
from textblob import TextBlob
en_blob = TextBlob('Simplilearn is one of the world’s leading certification training providers.')
en_blob.translate(to='es')
I am new to stackoverflow and asking my first question on this plateform so please pardon me if I my question is not following rules of this platform.
Textblob library uses Google API for translation functionality in the backend. Google has made some changes in the its API recently. Due to this reason TextBlob's translation feature has stopped working. I noticed that by making some minor changes in translate.py file (in your folder where all TextBlob files are located) as mentioned below, we can get rid of this error:
original code:
url = "http://translate.google.com/translate_a/t?client=webapp&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&ssel=0&tsel=0&kc=1"
change above code in translate.py to following:
url = "http://translate.google.com/translate_a/t?client=te&format=html&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&ssel=0&tsel=0&kc=1"
I have just tried this. It did not work for me the first times.
I restarted the Anaconda Prompt, restarted IPython. And re-ran my snippets and the problem go away after the fix. I am using Windows 10, I don't use virtual environment, the two files that were changed are:
C:\Users\behai\anaconda3\pkgs\textblob-0.15.3-py_0\site-packages\textblob\translate.py
C:\Users\behai\anaconda3\Lib\site-packages\textblob\translate.py
And I have also found that I have to do tab-indentation for the newline.
Added on 02/01/2021:
I did not do anything much at all. I applied the suggestion by Mr. Manish ( green tick above ). I had this 404 problem in the Anaconda environment. After applied the change above, I just restarted the "Anaconda Prompt (anaconda3)", and it worked.
This is the change as suggested above, in:
C:\Users\behai\anaconda3\Lib\site-packages\textblob\translate.py
# url = "http://translate.google.com/translate_a/t?client=webapp&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&ssel=0&tsel=0&kc=1"
url = "http://translate.google.com/translate_a/t?client=te&format=html&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&ssel=0&tsel=0&kc=1"
The file below get auto-updated:
C:\Users\behai\anaconda3\pkgs\textblob-0.15.3-py_0\site-packages\textblob\translate.py
It's fixed at https://github.com/sloria/TextBlob/pull/398
You should use a tag version with that fix.
# requirements/txt
textblob # git+https://github.com/sloria/TextBlob#0.17.1#=textBlob

AttributeError: module 'tensorflow' has no attribute 'div'

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' has no attribute 'div'
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.
tf.div was based on the old Python 2 division scheme and has been removed. You should use tf.truediv or tf.divide instead.

name ImageList is not defined in kaggle website

I was practicing some project from Kaggle notebook which is machine learning related code. and i am facing problem at one part. the error is NameError: name 'ImageList' is not defined. the Kaggle notebook link is this and the cell link is this. How can i fix it.
If you are getting this error even after defining the ImageList, Run the default first cell in the kaggle or make sure that U have run all the cells.
Even I faced the same issue during my initial practice on kaggle.

LGTM python no language data

I use LGTM for code quality analysis.
My LGTM badge recently went from "A+" to "no language data"
You can see it in my README.
I have no idea how to fix this and the LGTM site doesn't show any record of this error that I could find. I thought that I may need an lgtm.yml file but I have been using LGTM without one for the last few months without seeing this error.
Any help is appreciated.
This turned out to be an LGTM issue that was resolved automatically after my next git push. For anyone experiencing this issue in future, it is probably best to give them a few days to resolve it and keep pushing good updates to your repo which will trigger their system to update the quality.

Categories

Resources