gosha20777 / keras2cpp

it's a small library for running trained Keras 2 models from a native C++ code.
MIT License
183 stars 54 forks source link

Debug Assertion Failed (benchmark unit test) #8

Open martymcmodding opened 5 years ago

martymcmodding commented 5 years ago

Hello, messaged you before via mail. Following your instructions, I tried the unit test "benchmark" and it gives the same error I got earlier when experimenting with my own model.

Debug Assertion Failed! Program ...SCCN.exe File:c:\program files(x86)....\msvc\14.16.27023\include\vector Line: 122

Expression: cannot seek vector iterator after end

Because I suspected the input dimension being wrong in my model, I managed to make the conv3x3 unit test work just fine. I will run more tests and successively modify the unit test conv3x3 towards the benchmark one and see when it breaks.

EDIT: found the culprit (or at least how to trigger it). I modified the Conv3x3 test to use 1 channel input as follows:

test_x = np.random.rand(10, 3, 3, 1).astype('f').astype('f') test_y = np.random.rand(10, 1).astype('f') model = Sequential([ Conv2D(1, (3, 3), input_shape=(3, 3, 1)), Flatten(), Dense(1) ])

This works. But as soon as I increase the input size to anything larger than the kernel size of the Conv2D layer and load the generated model into the Cpp project.

test_x = np.random.rand(10, 9, 9, 1).astype('f').astype('f') test_y = np.random.rand(10, 1).astype('f') model = Sequential([ Conv2D(1, (3, 3), input_shape=(9, 9, 1)), Flatten(), Dense(1) ])

This was sufficient for me to trigger the error.

martymcmodding commented 5 years ago

Still relevant, haven't found a fix.

martymcmodding commented 5 years ago

Still an issue