Skip to content
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

Provide bindings for BaseEncoder for python encoders #704

Open
2 tasks
breznak opened this issue Oct 3, 2019 · 16 comments
Open
2 tasks

Provide bindings for BaseEncoder for python encoders #704

breznak opened this issue Oct 3, 2019 · 16 comments
Labels

Comments

@breznak
Copy link
Member

breznak commented Oct 3, 2019

So py-only encoders can derive from that class (same as c++).

Needed for: #691 , #259

@breznak
Copy link
Member Author

breznak commented Oct 3, 2019

@dkeeney would you mind looking at this, when you have time, please?

@dkeeney
Copy link

dkeeney commented Oct 3, 2019

Ok, I will take a look this weekend when I return.

@dkeeney
Copy link

dkeeney commented Oct 27, 2019

I am looking to see what to do next and this seems like a reasonable choice.
But I want input from everyone else...

Here are the things I am considering, in no particular order:

  • Base class for python encoders (this issue)
  • C# interface design
  • EncoderRegion in C++, a general encoder Region plugin.
  • A new Region for plots in C++ (for C++ and C# apps)
  • A Hot Gym example using NetworkAPI.
  • Rewrite NetworkAPI documentation. (comments in code is not enough)
  • New Region for Anomaly and AnomalyLikelyhood algorithms
  • New Region for SDRClassification algorithm
  • Merge VectorFileSensor, VectorFileEffector to a FileRegion
  • A means for C++ and C# NetworkAPI apps to use Regions written in Python.
  • A means for the Network class to process an OPF yaml model.
  • fix bindings\py\tests\algorithms\temporal_memory_test.py, line 58, see issue Possible Serialization problem in JSON mode. #645
  • Fix the remaining disabled unit tests

Or, anything else that seems more important?

Comments anyone?

@dkeeney
Copy link

dkeeney commented Oct 28, 2019

Well, it looks like I will be doing the pickle fix next instead. Issue #732
But that should not take too long, then I can get back to one of these projects.

@breznak
Copy link
Member Author

breznak commented Oct 28, 2019

Of those ideas, for me..

A new Region for plots in C++ (for C++ and C# apps)

this would be a nice to have 👍 a visualization of SDR + time-series plots. Although we don't want to get too complicated, there are other great tools for that here..hinting at the HTMpandaVis (?) tool discussed at the forums.

Base class for python encoders (this issue)

I think this would be great! Followed by

EncoderRegion in C++, a general encoder Region plugin.

although not sure if feasible.

A Hot Gym example using NetworkAPI.

👍

New Region for Anomaly and AnomalyLikelyhood algorithms

I'm not sure we need this, since TM.anomaly is now a part of TM, and users can choose which "anomaly method" is used.

anything else that seems more important?

personally, #714 is annoying me 🗡️

my 2c, thanks for your amazing work, David!! 💯

@dkeeney
Copy link

dkeeney commented Oct 28, 2019

Thanks for helping me prioritize.

I do need to fix the pickle thing for @fcr first.
Then I will take a look at doing the plots. I would not have guessed that that would be your top pick.

#714 needs to be fixed too. As you know I don't do much Python work but this caught me once as well.

The base class for python encoders project should be done by someone with lots of python experience although I can give a first cut at it. To work well with an EncoderRegion it should accept its arguments as **kwargs so they can be passed through from the Yaml parser. Other than that I guess its just putting common stuff in the base class.

@breznak
Copy link
Member Author

breznak commented Oct 28, 2019

the plots. I would not have guessed that that would be your top pick.

it is needed for tuning/understanding the models in RL problems. But thinking about it, not sure if there's a good enough c++ toolkit (opencv2 would likely do the job, but isn't that too much to include as a dep?), so we might want that only in python (?)..but that I'm thinking too much ahead, let's discuss when it's on plate.

@dkeeney
Copy link

dkeeney commented Oct 28, 2019

let's discuss when it's on plate.

Agreed. I am thinking that for Python we have a nice tool already. But for C++ and eventually C# apps trying out the HotGym example, we have nothing. opencv2 is too much. I was thinking we should be able to find a simple plotting tool for C++ someplace.

@breznak
Copy link
Member Author

breznak commented Oct 28, 2019

opencv2 is too much.

on the other take, cv2 would be well supported and ported to all platforms

@breznak breznak added the help wanted Extra attention is needed label Jun 2, 2020
@breznak
Copy link
Member Author

breznak commented Jun 2, 2020

@dkeeney when you have time, would you like looking at this issue?

@dkeeney
Copy link

dkeeney commented Jun 2, 2020

@breznak There seems to be more than one issue here. The title talks about py bindings for BaseEncoder. The text is talking about a plot package for C++. I assume we need both.

@breznak
Copy link
Member Author

breznak commented Jun 2, 2020

There seems to be more than one issue here. The title talks about py bindings for BaseEncoder. The text is talking about a plot package for C++. I assume we need both.

I'd keep this issue for py bindings for BaseEncoder.

plot tool (region?) might be useful, but we should check with exiting tools, ie with HTMPandaVis from @Zbysekz etc.. but let's keep that for a separate issue -> #748

@dkeeney
Copy link

dkeeney commented Jun 2, 2020

Ok, I will see what I can do for a binding for the BaseEncoder.

@dkeeney
Copy link

dkeeney commented Jun 2, 2020

Ok, I will see what I can do for a binding for the BaseEncoder.

The BaseEncoder class has no code. It is basically a template to force C++ sub classes to have serialization, dimensions, a reset() function, and an encode( ) function. I don't know how to force Python code to do that since it does not have virtual functions like those in C++.

@breznak do you have any ideas?

@breznak
Copy link
Member Author

breznak commented Jun 2, 2020

don't know how to force Python code to do that since it does not have virtual functions like those in C++

I think you can do

class BaseEncoder(object):
  def encode(input, output):
    raise NotImplementedError()

or there's ABCMeta
https://docs.python.org/2/library/abc.html

But I don;t know not to overcomplicate too much?
https://stackoverflow.com/questions/4714136/how-to-implement-virtual-methods-in-python

@dkeeney
Copy link

dkeeney commented Jun 2, 2020

Yes, but that would not be written in C++ as a binding but rather as pure Python.
I will try to put something for this in py/htm/encoders/BaseEncoder.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants