Closed dizcza closed 6 years ago
Weird, here is the exception I get when I run with NuPIC 1.0.4.dev0 and nupic.bindings 1.0.3.dev0:
Traceback (most recent call last):
File "script.py", line 45, in <module>
sp2 = load()
File "script.py", line 40, in load
sp2 = SpatialPooler.read(reader)
File "/Users/mtaylor/nta/nupic.core/bindings/py/src/nupic/bindings/algorithms.py", line 2784, in read
instance.convertedRead(proto)
File "/Users/mtaylor/nta/nupic.core/bindings/py/src/nupic/bindings/algorithms.py", line 2804, in convertedRead
self._initFromCapnpPyBytes(proto.as_builder().to_bytes()) # copy * 2
File "capnp/lib/capnp.pyx", line 1111, in capnp.lib.capnp._DynamicStructReader.as_builder (capnp/lib/capnp.cpp:24523)
File "capnp/lib/capnp.pyx", line 1122, in capnp.lib.capnp._DynamicStructReader.as_builder (capnp/lib/capnp.cpp:24422)
capnp.lib.capnp.KjException: src/kj/io.c++:259: failed: miniposix::read(fd, pos, max - pos): Bad file descriptor; fd = 3
stack: 0x10bd05844 0x10bd0a9ab 0x10bd0dc61 0x10bd0ce8c 0x10bd0c3af 0x10bd0c08f 0x10bcb1c2c 0x10bd0bebb 0x10bcb0ac5 0x10bc9adfe 0x10bc9fce9 0x10bca0258 0x10bc9f8f7 0x10bcde84c 0x10bbab9ae 0x10bb82243
libc++abi.dylib: terminating with uncaught exception of type kj::ExceptionImpl: src/kj/io.c++:259: failed: miniposix::read(fd, pos, max - pos): Bad file descriptor; fd = 3
stack: 0x10bd05844 0x10bd0a9ab 0x10bd0dc61 0x10bd0ce8c 0x10bd0c3af 0x10bd0c08f 0x10bcb1f3a 0x10bcb0899 0x10bcb2b9a 0x10bcb2d06 0x10bbe354f 0x10bbb385e 0x10aea2b04 0x10af25291 0x10af25278 0x10aeb2b01
@scottpurdy Is this expected behavior or a bug?
Looks like a bug! It isn't immediately obvious what is causing the exception. Is the serialization (builder.write_packed(f)
) actually writing out a file with the saved state? It could be there is a silent error during write that causes the read to fail.
So @lscheinkman and I were talking about this issue, and we don't think this is a bug. It just is not clear what the expected behavior is. The docs say sp compute takes a 1d array at this point, and Luiz recently added a runtime exception that fails fast when this is detected. (update your codebase @dizcza if you want to check)
I actually remember running into this issue when I was working on the topology video, but I just flattened the array and moved along. Thanks for reporting this, I think the error message and new docs will help.
SpatialPooler.compute
documentation states that inputVector
is treated as a one-dimensional array. As far as I could understand _calculateOverlap
function, flattening arrays loses their topology information, stored in original 2-dimensional (or a multi-dimensional) arrays, doesn't it? By topology information, I mean neighborhood pixels information - for example, convolution operation does use topology. Do you plan to include topology? Or I'm missing something here.
Thanks.
the code above throws an error
If I use 1-dimensional tuple for
inputDimensions
andcolumnDimensions
, everything works fine.