Obscure Looping Error in Theano - python

I am trying to simulate a repeat-until loop in Theano:
def method_a(arguments):
...
return result, theano.scan.until(t.eq(a,b))
I encountered the following strange behaviour. Let b be a constant. Whenever a is a constant, everything works fine. However, when a is a scalar, I get an error related to optimisation:
ERROR (theano.gof.opt): SeqOptimizer apply <theano.gof.opt.EquilibriumOptimizer object at 0x110d0d8d0>
ERROR (theano.gof.opt): Traceback:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "[...]/lib/python2.7/site-packages/theano/gof/opt.py", line 196, in apply
sub_prof = optimizer.optimize(fgraph)
File "[...]/python2.7/site-packages/theano/gof/opt.py", line 82, in optimize
ret = self.apply(fgraph, *args, **kwargs)
File "[...]/python2.7/site-packages/theano/gof/opt.py", line 1665, in apply
gopt.apply(fgraph)
File "[...]/python2.7/site-packages/theano/scan_module/scan_opt.py", line 1300, in apply
if self.belongs_to_set(nd, subset):
File "[...]/python2.7/site-packages/theano/scan_module/scan_opt.py", line 1286, in belongs_to_set
rep.op.inputs)
File "[...]/python2.7/site-packages/theano/scan_module/scan_utils.py", line 452, in equal_computations
dx.type.dtype == dy.type.dtype and
AttributeError: 'NoneTypeT' object has no attribute 'dtype'
I'd appreciate if someone could help me understand the error. I'm assuming the AttributeError doesn't refer to a or b, because I can print their dtype and see that they do have one. Other than that, I can't make any sense out of it.
[Edit] This is not a fatal error. The code runs normally and the process finishes with exit code 0. It looks like Theano is trying to optimise the graph and fails to do so, which doesn't really impact the program.

The traceback indicate that in the function equal_compuations(), we didn't cover all case, when doing some comparison.
I have a PR with a fix for it here:
https://github.com/Theano/Theano/pull/1928
thanks for the report.
Your [edit] section, indicate me that you cut some of the errors message. If this happear during optimization with a warning, it mean an optimization was just skipped. It is possible that the optimization just don't apply, but it could be possible that with the fix, now the optimization apply. If that is the case, there could be some speed up with the fix.

Related

Error for word2vec with GoogleNews-vectors-negative300.bin

the version of python is 3.6
I tried to execute my code but, there are still some errors as below:
Traceback (most recent call last):
File
"C:\Users\tmdgu\Desktop\NLP-master1\NLP-master\Ontology_Construction.py",
line 55, in
, binary=True)
File "E:\Program
Files\Python\Python35-32\lib\site-packages\gensim\models\word2vec.py",
line 1282, in load_word2vec_format
raise DeprecationWarning("Deprecated. Use gensim.models.KeyedVectors.load_word2vec_format instead.")
DeprecationWarning: Deprecated. Use
gensim.models.KeyedVectors.load_word2vec_format instead.
how to fix the code? or is the path to data wrong?
This is just a warning, not a fatal error. Your code likely still works.
"Deprecation" means a function's use has been marked by the authors as no longer encouraged.
The function typically still works, but may not for much longer – becoming unreliable or unavailable in some future library release. Often, there's a newer, more-preferred way to do the same thing, so you don't trigger the warning message.
Your warning message points you at the now-preferred way to load word-vectors of that format: use KeyedVectors.load_word2vec_format() instead.
Did you try using that, instead of whatever line of code (not shown in your question) that you were trying before seeing the warning?

Error Traceback is not descriptive when using multiprocessing pool

Hi i am using python multiprocessing module and the problem is when i get an error from a code that has been executed in another thread, the Traceback is only pointing to multiprocessing/pool.py", line 520 instead of the line number of what caused the error exactly.
Traceback (most recent call last):
File "analyzer.py", line 196, in <module>
for ret in pool.imap(ProcessRow, rows):
File "/usr/lib64/python2.6/multiprocessing/pool.py", line 520, in next
raise value
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
so line 196 in analyzer.py is when i call for ret in pool.imap(ProcessRow, rows):
so it's completely not helpful....Any advice ?
The error is raised from ProcessRow() or some function called by it (why is your function CamelCaseUpper?).
You are not getting a proper stack trace, because the exception is actually pickled from the subprocess (hence the name of the module: multiprocessing) your code is executing in and is then raised again in the manager process. Hence the stack trace shows up as if it was local (while it is actually an exception raised in the subprocess).
The preferred way of dealing with this seems to be to catch the exception in the forked of code and printing a proper stacktrace from there.

"BUG IN FGRAPH.REPLACE OR A LISTENER" error reported when compile theano function

I encountered an stranger error as below, when compile my theano function. I am using the version 0.7 of theano. I hope a quick work around is available. The function dump is here.
<<!! BUG IN FGRAPH.REPLACE OR A LISTENER !!>> <type 'exceptions.AssertionError'> local_shape_to_shape_i
ERROR (theano.gof.opt): Optimization failure due to: local_shape_to_shape_i
ERROR (theano.gof.opt): TRACEBACK:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/theano/gof/opt.py", line 1527, in process_node
fgraph.replace_all_validate(repl_pairs, reason=lopt)
File "/usr/local/lib/python2.7/dist-packages/theano/gof/toolbox.py", line 259, in replace_all_validate
fgraph.replace(r, new_r, reason=reason, verbose=False)
File "/usr/local/lib/python2.7/dist-packages/theano/gof/fg.py", line 502, in replace
self.change_input(node, i, new_r, reason=reason)
File "/usr/local/lib/python2.7/dist-packages/theano/gof/fg.py", line 442, in change_input
self.__import_r__([new_r], reason=reason)
File "/usr/local/lib/python2.7/dist-packages/theano/gof/fg.py", line 257, in __import_r__
self.__import__(apply_node, reason=reason)
File "/usr/local/lib/python2.7/dist-packages/theano/gof/fg.py", line 365, in __import__
assert node not in self.apply_nodes
AssertionError
This error message appears when a bug in a Theano optimization causes an invalid graph modification.
If you ever see "Optimization failure due to: <something>", try the following:
Search the internet, and the theano-users mailing list in particular, for the message including the specific <something> (in this case <something> is "local_shape_to_shape_i"). You may find a message indicating that the bug has already been identified. If it's been reported to the Theano developers then it may have already been fixed though you may need to update to the bleeding edge version of Theano direct from GitHub (i.e. pip install --upgrade may not be sufficient).
Even if you can't find any mention online, try updating to the bleeding edge version if that's possible for you. It may have already been fixed.
If the latest bleeding edge version still exhibits the bug then report it on the theano-users mailing list.
Ignore it. Optimization failures do not cause invalid computations. The only side effect (at least in theory) is that the computation may not be as efficient as it might otherwise be.

Get CPU temperature in python on windows

Basically, I want to read the CPU temperature with Python. Please explain in layman's terms as I have never done this on Windows before nor have I had to work with wmi.
This is what I have at the moment:
import wmi
w = wmi.WMI(namespace="root\wmi")
temperature_info = w.MSAcpi_ThermalZoneTemperature()[0]
print temperature_info.CurrentTemperature
(I got this code from this thread: Accessing CPU temperature in python)
However, on running the script, I get this error:
Traceback (most recent call last):
File "C:\Users\Ryan\Desktop\SerialSystemMonitor", line 4, in <module>
temperature_info = w.MSAcpi_ThermalZoneTemperature()[0]
File "C:\Python27\lib\site-packages\wmi.py", line 819, in query
handle_com_error ()
File "C:\Python27\lib\site-packages\wmi.py", line 241, in handle_com_error
raise klass (com_error=err)
x_wmi: <x_wmi: Unexpected COM Error (-2147217396, 'OLE error 0x8004100c', None, None)>
What can I do to get this to work?
According to the MSDN page on WMI Error Constants, the error you have received is:
WBEM_E_NOT_SUPPORTED
2147749900 (0x8004100C)
Feature or operation is not supported.
Presumably, then, your CPU does not provide temperature information through WMI. If your CPU doesn't expose this information, you're probably out of luck, at least as far as a straightforward solution in Python goes.
I assume you've tried the other option given in the answer you linked, using Win32_TemperatureProbe(); if you haven't, try it.
Just execute as Admin. It's work for me.

grid.py not giving output

I am using LibSVM and I used GRID.py for SVM. But the problem is I ran it grid.py more than hour but it's not giving any output. The error message it gives as follows
%%%%%%%%%%%%%%%%%%%%%%%
Traceback (most recent call last):
File "grid.py", line 266, in run
if rate is None: raise RuntimeError('get no rate')
RuntimeError: get no rate
worker local quit.
%%%%%%%%%%%%%%%
Can anybody tell me what's problem? And what is this "worker local quit"?
If anybody want to know more information about implementation or GRID.py please feel free to ask. I am having more than 9000 rows with 8 different columns as dataset
Are you calling GRID.py with either the parameter -log2c or -log2g?
It seems that the problem arises when LocalWorker.run_one returns None.

Categories