我正在尝试使用 Neupy python 库使用 Levenberg-Marquardt 优化器算法构建一个简单的前馈网络,但它不会编译,因为它似乎缺少 scan_perform 模块。如果我将优化器算法更改为 GradientDescent,那么它可以正常工作。
重现错误所需的代码是:
from neupy import algorithms
from neupy.layers import *
net = Input(2) >> Sigmoid(2) >> Linear(1)
opt = algorithms.LevenbergMarquardt(net)
我得到的错误是:
You can find the C code in this temporary file: /tmp/theano_compilation_error_8yf9iyd4
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:11860:69: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12617:21: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12618:22: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12619:19: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12626:24: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12627:25: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12628:22: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12629:13: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12630:13: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12631:13: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12686:24: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12687:25: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12688:22: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12689:13: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12690:13: is not found.
library owlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12691:13: is not found.
Traceback (most recent call last):
File "/home/gus/anaconda3/lib/python3.8/site-packages/theano/scan_module/scan_perform_ext.py", line 48, in <module>
raise ImportError()
ImportError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/gus/anaconda3/lib/python3.8/site-packages/theano/scan_module/scan_perform_ext.py", line 63, in <module>
raise ImportError()
ImportError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/gus/Documents/UNSW_work/code/python/latent_variables/nn_test_neupy2.py", line 12, in <module>
opt = algorithms.LevenbergMarquardt(net)
File "/home/gus/anaconda3/lib/python3.8/site-packages/neupy/algorithms/gd/base.py", line 113, in __init__
super(GradientDescent, self).__init__(connection, **options)
File "/home/gus/anaconda3/lib/python3.8/site-packages/neupy/algorithms/constructor.py", line 291, in __init__
super(ConstructibleNetwork, self).__init__(*args, **kwargs)
File "/home/gus/anaconda3/lib/python3.8/site-packages/neupy/algorithms/constructor.py", line 163, in __init__
self.init_methods()
File "/home/gus/anaconda3/lib/python3.8/site-packages/neupy/algorithms/constructor.py", line 338, in init_methods
train_epoch=theano.function(
File "/home/gus/anaconda3/lib/python3.8/site-packages/theano/compile/function.py", line 306, in function
fn = pfunc(params=inputs,
File "/home/gus/anaconda3/lib/python3.8/site-packages/theano/compile/pfunc.py", line 483, in pfunc
return orig_function(inputs, cloned_outputs, mode,
File "/home/gus/anaconda3/lib/python3.8/site-packages/theano/compile/function_module.py", line 1841, in orig_function
fn = m.create(defaults)
File "/home/gus/anaconda3/lib/python3.8/site-packages/theano/compile/function_module.py", line 1714, in create
_fn, _i, _o = self.linker.make_thunk(
File "/home/gus/anaconda3/lib/python3.8/site-packages/theano/gof/link.py", line 697, in make_thunk
return self.make_all(input_storage=input_storage,
File "/home/gus/anaconda3/lib/python3.8/site-packages/theano/gof/vm.py", line 1087, in make_all
thunks.append(node.op.make_thunk(node,
File "/home/gus/anaconda3/lib/python3.8/site-packages/theano/scan_module/scan_op.py", line 925, in make_thunk
from . import scan_perform_ext
File "/home/gus/anaconda3/lib/python3.8/site-packages/theano/scan_module/scan_perform_ext.py", line 120, in <module>
cmodule.GCC_compiler.compile_str(dirname, code, location=loc,
File "/home/gus/anaconda3/lib/python3.8/site-packages/theano/gof/cmodule.py", line 2398, in compile_str
raise Exception('Compilation failed (return status=%s): %s' %
Exception: ('The following error happened while compiling the node', for{cpu,scan_fn}(Elemwise{Mul}[(0, 0)].0, Subtensor{int64:int64:int8}.0, Elemwise{Mul}[(0, 0)].0, Elemwise{Mul}[(0, 0)].0, Elemwise{Mul}[(0, 0)].0, Elemwise{Mul}[(0, 0)].0, Reshape{1}.0, Elemwise{sub,no_inplace}.0, Elemwise{Composite{scalar_sigmoid((i0 + i1))}}[(0, 0)].0, InplaceDimShuffle{1,0}.0, Elemwise{sub,no_inplace}.0, MakeVector{dtype='int64'}.0, Alloc.0, InplaceDimShuffle{1,0}.0, InplaceDimShuffle{1,0}.0), '\n', 'Compilation failed (return status=1): /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp: In function ‘PyObject* __Pyx_PyCFunction_FastCall(PyObject*, PyObject**, Py_ssize_t)’:. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:11860:69: error: too many arguments to function. 11860 | return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL);. | ^. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp: In function ‘void __Pyx__ExceptionSave(PyThreadState*, PyObject**, PyObject**, PyObject**)’:. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12617:21: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?. 12617 | *type = tstate->exc_type;. | ^~~~~~~~. | curexc_type. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12618:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?. 12618 | *value = tstate->exc_value;. | ^~~~~~~~~. | curexc_value. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12619:19: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?. 12619 | *tb = tstate->exc_traceback;. | ^~~~~~~~~~~~~. | curexc_traceback. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp: In function ‘void __Pyx__ExceptionReset(PyThreadState*, PyObject*, PyObject*, PyObject*)’:. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12626:24: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?. 12626 | tmp_type = tstate->exc_type;. | ^~~~~~~~. | curexc_type. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12627:25: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?. 12627 | tmp_value = tstate->exc_value;. | ^~~~~~~~~. | curexc_value. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12628:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?. 12628 | tmp_tb = tstate->exc_traceback;. | ^~~~~~~~~~~~~. | curexc_traceback. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12629:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?. 12629 | tstate->exc_type = type;. | ^~~~~~~~. | curexc_type. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12630:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?. 12630 | tstate->exc_value = value;. | ^~~~~~~~~. | curexc_value. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12631:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?. 12631 | tstate->exc_traceback = tb;. | ^~~~~~~~~~~~~. | curexc_traceback. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp: In function ‘int __Pyx__GetException(PyThreadState*, PyObject**, PyObject**, PyObject**)’:. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12686:24: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?. 12686 | tmp_type = tstate->exc_type;. | ^~~~~~~~. | curexc_type. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12687:25: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?. 12687 | tmp_value = tstate->exc_value;. | ^~~~~~~~~. | curexc_value. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12688:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?. 12688 | tmp_tb = tstate->exc_traceback;. | ^~~~~~~~~~~~~. | curexc_traceback. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12689:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?. 12689 | tstate->exc_type = local_type;. | ^~~~~~~~. | curexc_type. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12690:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?. 12690 | tstate->exc_value = local_value;. | ^~~~~~~~~. | curexc_value. /home/gus/.theano/compiledir_Linux-5.4--lowlatency-x86_64-with-glibc2.10-x86_64-3.8.3-64/scan_perform/mod.cpp:12691:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?. 12691 | tstate->exc_traceback = local_tb;. | ^~~~~~~~~~~~~. | curexc_traceback. ')
正如我上面所说,如果我将底线更改为opt = algorithms.GradientDescent(net)
,它可以正常工作,它只是 LevenbergMarquardt 和 Hessian 以及其他基于牛顿方法的方法。
知道如何解决这个问题吗?