-1

I have converted my dataset exactly in the form of the mnist.pkl.gz file and it runs for the logistic_sgd.py and mlp.py programs given in the Theano deeplearning tutorial PDF (University of Montreal). However on running the CNN.py file it gives a huge error which is difficult to understand. Can anyone who has succesfully run the CNN.py program for a different dataset help me out here as I am totally clueless about what the error is. My training set has 1176 entries and my validation and test set has 168 entries each. Maybe the problem is with the batch size. If so can someone please suggest me an appropriate batch size?

I am using the Spyder GUI for Python 2.7 that comes with the Anaconda Bundle.

Error occurs soon after printing '... building model'

Code Snippet:

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)
)

Prompt at console as soon as error occurs:

... 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')

Then the following error message appears.

Error message:

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)>)]")
DBedrenko
  • 4,871
  • 4
  • 38
  • 73
  • 2
    Please provide more specific information about what you have tried, full details of the errors you are getting, code samples, data samples, expected outputs, etc. – Daniel Renshaw Jun 01 '15 at 09:17
  • The code is exactly the same as given in the University of Montreal PDF. The only changes I have done is taken a different dataset which is similar to the mnist.pkl.gz file. Only difference is that mnist dataset has 70000 samples and my dataset has 1512 samples. The error message is quite big. I'll try to take a screen shot of a part of it and post it here. – Pratik Vaishnavi Jun 01 '15 at 09:20
  • Post all the things Daniel mentioned. And don't post screenshots: post everything in text form. – DBedrenko Jun 01 '15 at 09:24
  • the entire message being displayed on the console once i run the program is too long and so im posting the ending part of it. Hope this helps. Otherwise please let me know what else I can do to help. – Pratik Vaishnavi Jun 01 '15 at 09:29
  • @Pratik you can edit your question to add additional information. That is more helpful than adding an unformatted comment. I've copied the error message into your question but I don't know where the lines breaks should go, if any. Please edit the answer to format the error message as you see it, please also add the command line you are using that generates the error, including all the command line flags you're using. – Daniel Renshaw Jun 01 '15 at 09:40
  • I am sorry, I am new to the forum. Thanx for your advice and i'll keep it in mind. I'll add the necessary info you have asked for in the question itself. – Pratik Vaishnavi Jun 01 '15 at 09:55

2 Answers2

0

I encouraged you to add more information (thanks for that) so felt obliged to help as far as I can, but unfortunately that may not be much. Hopefully others can add better answers.

I don't think the error is occurring within the code snippet you provided. Yes, it's after the '... building the model' message, but I think it's further on. It's probably generating the error at a theano.function call.

Your problem appears to be in the C++ toolchain on your system. I would suggest searching for more information with respect to the "undefined reference to __imp_PyExc_ImportError" message.

For example, this StackOverflow question suggests adding -D MS_WIN64 to the command line. But this is probably an internal command line, not the one you are using originally.

I don't understand why it works for one dataset but not another.

Community
  • 1
  • 1
Daniel Renshaw
  • 33,729
  • 8
  • 75
  • 94
  • Thanx for the response. Any sort of help is really appreciated. I'll try to follow the cue you have provided. I designed my dataset exactly as the mnist.pkl.gz dataset file still it isn't working. Just now I tried to use different batchsizes, it worked for one but displayed validation error as nan% – Pratik Vaishnavi Jun 01 '15 at 10:36
  • Ah, so CNN.py isn't working with any dataset? If that is the case then it's probably not anything to do with the data or the config (e.g. batch size), it's probably just a system config error, e.g. how Anaconda and its dependencies such as MinGW are installed. – Daniel Renshaw Jun 01 '15 at 10:37
  • No, it is working perfectly fine for mnist.pkl.gz. And i jsut now learnt that it is also working for my dataset but only for one particular batch size. But in this case it is showing validation error as nan%. I had a similar problem while running the mlp.py file but then it started calculating correct validation error once i reduced the batch size. For CNN.py when i change the batch size it shows error as i have indicated in the question – Pratik Vaishnavi Jun 01 '15 at 10:44
0

There was some problem in my laptop only. It is running fine on a different computer.