Keras strange crash - python

Training model in Keras I get exception at some epoch:
Exception ignored in: <bound method BaseSession.__del__ of <tensorflow.python.client.session.Session object at 0x7f036d74b7f0>>
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 686, in __del__
TypeError: 'NoneType' object is not callable
What could be reason of such behaviour?

This might be caused by the Cache file, you can try deleting the pycache folder. This works for me.
I am using the Tensorflow version.

Related

AttributeError: 'module' object has no attribute 'MCA'

I want to do correspondence analysis for the categorical features in my dataset but get this error.
import mca
mca_counts = mca.MCA(test.drop('ID', axis=1))
Traceback (most recent call last):
File "<pyshell#22>", line 1, in <module>
mca_counts = mca.MCA(test.drop('ID', axis=1))
AttributeError: 'module' object has no attribute 'MCA'
Apparently, the latest version of the library in PyPI is 1.0, where the class is called mca.mca. It was renamed to mca.MCA only in 1.0.1, but that version for some reason has never made it to PyPI. Consider either using mca.mca, or reinstalling it from git, or finding something less abandoned.

Why does the following attribute error occur?

I get the following error when trying to execute the following in Python with the PuLP library
for i in range(0, items):
print('x{0} = {1}'.format(i+1, value('x{0}'.format(i+1))))
That is my code which throws the following error
Traceback (most recent call last):
File "C:/Python34/knapsack.py", line 81, in <module>
print('x{0} = {1}'.format(i+1, value('x{0}'.format(i+1))))
File "C:\Python34\lib\site-packages\pulp-1.6.1-py3.4.egg\pulp\pulp.py", line 1990, in value
else: return x.value()
AttributeError: 'str' object has no attribute 'value'
My question is why does this not work. Splitting the print statement tends to work correctly.
The value method expects a PuLP variable object, not a string with the same name as one.
In order to evaluate your string back to a python variable, you need to eval it, so that would look like.
value(eval('x{0}'.format(i+1)))

Python Try/Except firing TypeError despite Except clause

I'm following along with the Python docs for try/except with the following effort:
def profile_check(self):
try:
profile = self.profile_type
return profile
except TypeError:
...
self.profile_type is a field in a Django model which doesn't exist in this case (therefore it returns as None). However, something seems to be missing, because it never moves on to the actions for except, rather it immediately throws the TypeError exception:
>>> a.profile_check()
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: 'NoneType' object is not callable
This is my first effort with try-catch, so I know it's something basic.
First off, your problem is that profile_check is set to None for some reason. That's why it's giving you that error when you call it.
As for your try/catch problem, if a variable doesn't exist, then the Python interpreter will throw a NameError at you. Try substituting TypeError for that.
I can't help you with your profile_check-is-None situation though without anymore context though. Sorry!

AttributeError, why?

I'm writing a program that solves a tetravex and I encountered this error:
AttributeError: 'list' object has no attribute 'PlacementList'.
I tried everything I know but don't know why I'm getting that error. Could you please tell me what I did wrong?
This is a pastebin link to my code: http://pastebin.com/d1WdbCUu
It happens when you are trying to get PlacementList attribute of a list, obviously.
Here is the example:
>>> a = []
>>> a.PlacementList
Traceback (most recent call last):
File "<pyshell#49>", line 1, in <module>
a.PlacementList
AttributeError: 'list' object has no attribute 'PlacementList'
Just find the code where something similar happens - you are trying to get PlacementList attribute of the object that can be of type list.

python "'NoneType' object has no attribute 'encode'"

I wrote this tiny Python snippet that scrapes a feed and prints it out. When I run the code, something in the feed triggers the error message you see here as my question. Here's the complete console output on error:
> Traceback (most recent call last):
> File "/home/vijay/ffour/ffour5.py",
> line 20, in <module>
> myfeed() File "/home/vijay/ffour/ffour5.py", line
> 15, in myfeed
> sys.stdout.write(entry["title"]).encode('utf-8')
> AttributeError: 'NoneType' object has
> no attribute 'encode'
> sys.stdout.write(entry["title"]).encode('utf-8')
This is the culprit. You probably mean:
sys.stdout.write(entry["title"].encode('utf-8'))
(Notice the position of the last closing bracket.)
Lets try to clear up some of the confusion in the exception message.
The function call
sys.stdout.write(entry["title"])
Returns None. The ".encode('utf-8')" is a call to the encode function on what is returned by the above function.
The problem is that None doesn't have an encode function (or an encode attribute) and so you get an attribute error that names the type you were trying to get an attribute of and the attribute you were trying to get.

Categories