无法为另一个数据集

时间:2015-06-01 09:10:22

标签: python theano deep-learning

我已经完全以mnist.pkl.gz文件的形式转换了我的数据集,它运行了Theano deeplearning教程PDF(蒙特利尔大学)中给出的logistic_sgd.py和mlp.py程序。但是,在运行CNN.py文件时,它会产生一个很难理解的巨大错误。任何成功运行CNN.py程序以获取不同数据集的人都可以帮助我,因为我完全不知道错误是什么。 我的训练集有1176个条目,我的验证和测试集各有168个条目。也许问题在于批量大小。如果是这样,有人可以建议我适当的批量大小吗?

我正在使用Anaconda Bundle附带的Spyder GUI for Python 2.7。

打印' ...构建模型'

后很快就会出现错误

代码段:

print '... building the model'

# Reshape matrix of rasterized images of shape (batch_size, 28 * 28)
# to a 4D tensor, compatible with our LeNetConvPoolLayer
# (28, 28) is the size of MNIST images.
layer0_input = x.reshape((batch_size, 1, 28, 28))

# Construct the first convolutional pooling layer:
# filtering reduces the image size to (28-5+1 , 28-5+1) = (24, 24)
# maxpooling reduces this further to (24/2, 24/2) = (12, 12)
# 4D output tensor is thus of shape (batch_size, nkerns[0], 12, 12)
layer0 = LeNetConvPoolLayer(
    rng,
    input=layer0_input,
    image_shape=(batch_size, 1, 28, 28),
    filter_shape=(nkerns[0], 1, 5, 5),
    poolsize=(2, 2)
)

发生错误时立即在控制台提示:

... bulding the modelWARNING (theano.gof.compilelock): Overriding existing lock by dead process '4396'(I am process '3624')
WARNING:theano.gof.compilelock:Overriding exisiting lock by dead process '4396' (I am process '3624')

然后会出现以下错误消息。

错误讯息:

Traceback (most recent call last):

  File "<ipython-input-17-931f7529f484>", line 1, in <module>
    runfile('C:/Users/pratik18v/Documents/Python Scripts/CNN.py', wdir='C:/Users/pratik18v/Documents/Python Scripts')

  File "C:\Users\pratik18v\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 682, in runfile
    execfile(filename, namespace)

  File "C:\Users\pratik18v\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "C:/Users/pratik18v/Documents/Python Scripts/CNN.py", line 339, in <module>
    evaluate_lenet5()

  File "C:/Users/pratik18v/Documents/Python Scripts/CNN.py", line 218, in evaluate_lenet5
    y: test_set_y[index * batch_size: (index + 1) * batch_size]

  File "C:\Users\pratik18v\Anaconda\lib\site-packages\theano\compile\function.py", line 266, in function
    profile=profile)

  File "C:\Users\pratik18v\Anaconda\lib\site-packages\theano\compile\pfunc.py", line 511, in pfunc
    on_unused_input=on_unused_input)

  File "C:\Users\pratik18v\Anaconda\lib\site-packages\theano\compile\function_module.py", line 1466, in orig_function
    defaults)

  File "C:\Users\pratik18v\Anaconda\lib\site-packages\theano\compile\function_module.py", line 1324, in create
    input_storage=input_storage_lists)

  File "C:\Users\pratik18v\Anaconda\lib\site-packages\theano\gof\link.py", line 519, in make_thunk
    output_storage=output_storage)[:3]

  File "C:\Users\pratik18v\Anaconda\lib\site-packages\theano\gof\vm.py", line 897, in make_all
    no_recycling))

  File "C:\Users\pratik18v\Anaconda\lib\site-packages\theano\gof\op.py", line 1002, in make_thunk
    compute_map, no_recycling)

  File "C:\Users\pratik18v\Anaconda\lib\site-packages\theano\gof\op.py", line 739, in make_thunk
    output_storage=node_output_storage)

  File "C:\Users\pratik18v\Anaconda\lib\site-packages\theano\gof\cc.py", line 1073, in make_thunk
    keep_lock=keep_lock)

  File "C:\Users\pratik18v\Anaconda\lib\site-packages\theano\gof\cc.py", line 1015, in __compile__
    keep_lock=keep_lock)

  File "C:\Users\pratik18v\Anaconda\lib\site-packages\theano\gof\cc.py", line 1442, in cthunk_factory
    key=key, lnk=self, keep_lock=keep_lock)

  File "C:\Users\pratik18v\Anaconda\lib\site-packages\theano\gof\cmodule.py", line 1076, in module_from_key
    module = lnk.compile_cmodule(location)

  File "C:\Users\pratik18v\Anaconda\lib\site-packages\theano\gof\cc.py", line 1354, in compile_cmodule
    preargs=preargs)

  File "C:\Users\pratik18v\Anaconda\lib\site-packages\theano\gof\cmodule.py", line 2010, in compile_str
    (status, compile_stderr.replace('\n', '. ')))

Exception: ('The following error happened while compiling the node', ConvOp{('imshp', (1, 28, 28)),('kshp', (5, 5)),('nkern', 20),('bsize', 100),('dx', 1),('dy', 1),('out_mode', 'valid'),('unroll_batch', 5),('unroll_kern', 2),('unroll_patch', False),('imshp_logical', (1, 28, 28)),('kshp_logical', (5, 5)),('kshp_logical_top_aligned', True)}(Reshape{4}.0, <TensorType(float64, 4D)>), '\n', "Compilation failed (return status=1): C:\\Users\\PRATIK~1\\AppData\\Local\\Temp\\cchTvCFS.o: In function `instantiate':\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:1128: undefined reference to `__imp_PyExc_TypeError'\r. C:\\Users\\PRATIK~1\\AppData\\Local\\Temp\\cchTvCFS.o: In function `run':\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:297: undefined reference to `__imp__Py_NoneStruct'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:322: undefined reference to `__imp_PyExc_ValueError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:328: undefined reference to `__imp_PyExc_RuntimeError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:356: undefined reference to `__imp_PyExc_NotImplementedError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:393: undefined reference to `__imp__Py_NoneStruct'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:408: undefined reference to `__imp_PyExc_ValueError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:442: undefined reference to `__imp_PyExc_NotImplementedError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:463: undefined reference to `__imp_PyExc_RuntimeError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:371: undefined reference to `__imp_PyExc_TypeError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:377: undefined reference to `__imp_PyExc_RuntimeError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:1095: undefined reference to `__imp__Py_NoneStruct'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:1094: undefined reference to `__imp__Py_NoneStruct'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:1093: undefined reference to `__imp__Py_NoneStruct'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:477: undefined reference to `__imp__Py_NoneStruct'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:492: undefined reference to `__imp_PyExc_ValueError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:1058: undefined reference to `__imp_PyExc_NotImplementedError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:1029: undefined reference to `__imp__Py_NoneStruct'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:1064: undefined reference to `__imp_PyExc_RuntimeError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:457: undefined reference to `__imp_PyExc_TypeError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:526: undefined reference to `__imp_PyExc_NotImplementedError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:547: undefined reference to `__imp_PyExc_RuntimeError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:414: undefined reference to `__imp_PyExc_RuntimeError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:761: undefined reference to `__imp_PyExc_ValueError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:767: undefined reference to `__imp_PyExc_RuntimeError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:541: undefined reference to `__imp_PyExc_TypeError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:620: undefined reference to `__imp_PyExc_ValueError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:903: undefined reference to `__imp_PyExc_RuntimeError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:599: undefined reference to `__imp_PyExc_ValueError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:605: undefined reference to `__imp_PyExc_RuntimeError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:782: undefined reference to `__imp_PyExc_ValueError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:803: undefined reference to `__imp_PyExc_ValueError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:835: undefined reference to `__imp_PyExc_ValueError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:498: undefined reference to `__imp_PyExc_RuntimeError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:897: undefined reference to `__imp_PyExc_AssertionError'\r. C:/Users/pratik18v/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/tmpjmrfis/mod.cpp:827: undefined reference to `__imp_PyExc_ValueError'\r. C:\\Users\\PRATIK~1\\AppData\\Local\\Temp\\cchTvCFS.o: In function `_import_array':\r. C:/Users/pratik18v/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1654: undefined reference to `__imp_PyCObject_Type'\r. C:/Users/pratik18v/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1655: undefined reference to `__imp_PyExc_RuntimeError'\r. C:/Users/pratik18v/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1656: undefined reference to `__imp_PyExc_ImportError'\r. C:/Users/pratik18v/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1677: undefined reference to `__imp_PyExc_RuntimeError'\r. C:/Users/pratik18v/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1677: undefined reference to `__imp_PyExc_ImportError'\r. C:/Users/pratik18v/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1636: undefined reference to `__imp_PyExc_ImportError'\r. C:/Users/pratik18v/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1699: undefined reference to `__imp_PyExc_RuntimeError'\r. C:/Users/pratik18v/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1699: undefined reference to `__imp_PyExc_ImportError'\r. C:/Users/pratik18v/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1642: undefined reference to `__imp_PyExc_AttributeError'\r. C:/Users/pratik18v/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1642: undefined reference to `__imp_PyExc_ImportError'\r. C:/Users/pratik18v/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1663: undefined reference to `__imp_PyExc_RuntimeError'\r. C:/Users/pratik18v/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1663: undefined reference to `__imp_PyExc_ImportError'\r. collect2.exe: error: ld returned 1 exit status\r. ", "[ConvOp{('imshp', (1, 28, 28)),('kshp', (5, 5)),('nkern', 20),('bsize', 100),('dx', 1),('dy', 1),('out_mode', 'valid'),('unroll_batch', 5),('unroll_kern', 2),('unroll_patch', False),('imshp_logical', (1, 28, 28)),('kshp_logical', (5, 5)),('kshp_logical_top_aligned', True)}(<TensorType(float64, (False, True, False, False))>, <TensorType(float64, 4D)>)]")

2 个答案:

答案 0 :(得分:0)

我鼓励您添加更多信息(感谢您),因此我觉得有义务尽我所能,但不幸的是,这可能并不多。希望其他人可以添加更好的答案。

我认为您提供的代码段中不会发生错误。是的,它是在'...构建模型'消息之后,但我认为它还在继续。它可能会在theano.function调用时生成错误。

您的问题似乎出现在系统的C ++工具链中。我建议搜索有关“未定义的__imp_PyExc_ImportError引用”消息的更多信息。

例如,this StackOverflow question建议在命令行中添加-D MS_WIN64。但这可能是一个内部命令行,而不是您最初使用的命令行。

我不明白为什么它适用于一个数据集但不适用于另一个数据集。

答案 1 :(得分:0)

我的笔记本电脑只有一些问题。它在另一台计算机上运行良好。