-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cereal for TMRegion #472
Cereal for TMRegion #472
Conversation
This is a new clean branch. The other one was so messed up I could not trust it. The Network class has two STL objects being serialized. One for regions and one for links. Whichever one is first is ok but the second one seems to be out of synch with the stream and crashes. I tried putting just a simple int field deserialized after the first STL object and it came up with the wrong value. This did not show up with the SPRegion PR because I did not happen to have any Links in the test. Well, I am out of time so I will have to finish this when I get back. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a question to the TM. reset, otherwise looks good
src/nupic/regions/TMRegion.hpp
Outdated
if (args_.init) { | ||
// Restore algorithm state | ||
nupic::algorithms::temporal_memory::TemporalMemory* tm = new nupic::algorithms::temporal_memory::TemporalMemory(); | ||
tm_.reset(tm); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the TM::reset() is questionable here, since it didnt have to be called prior to saving
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reset just assigns the raw TM pointer to the shared_ptr. Perhaps I should use a make_shared( ) here in this case since this is a simple allocation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I should use a make_shared( ) here in this case since this is a simple allocation.
ok, the name confused me into a TM.reset. Maybe rename the method to resetTMPointer or something? but it can stay as is
CI simple problem:
|
I pushed again without the marker field :) That was the field I serialized after the first STL. I missed the declaration when I took it back out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, thank you David!
…nto cereal-TMRegion2
…nto cereal-TMRegion2
Funny how problems look so much simpler after coming back from a vacation.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this looks real good now! Thank you 👍
Funny how problems look so much simpler after coming back from a vacation.
indeed, sometimes we just need to take a rest from the problems.
So if you have more than one object for each sequence iteration, put them in a container and add save_ar( ) and load_ar( ) to the container. For an example, see TemporalMemory.hpp line 455.
this is great finding!
The regions_ member variable in the Network class is now a std::map( ) so it is easier to serialize. But this map is only seen inside the class. Outside the Network class regions is a Collection, obtained via the getRegions( ) call so this does not change the API.
Cool! The better API would use std::map instead, and internally Collection could have extended from std::map. Good as is now, do you want to break the API for the sake of getting rid of Collection, or leave things stable as is now?
* The list of regions registered with the Network. | ||
* Internally this is a map so it is easy to serialize | ||
* but externally this is a Collection object so it | ||
* retains API compatability. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is perferct! Thanks 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The better API would use std::map instead, and internally Collection could have extended from std::map.
Collection contains both a vector of pairs and a map of indexes into the vector. It would be difficult to extend from map and get a class that can also be indexed like a vector to get a pair.
... for the sake of getting rid of Collection, ...
The Collection is still being used in several other places as well so it will take a while before we can get rid of it. Lets let it live in the API for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@breznak approved these changes
Thanks for doing the review for me.
Adds Cereal for TMRegion
Replaces #421