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

Try to create iPython online notebook in google Collab #563

Open
cyberslam opened this issue Jul 14, 2019 · 14 comments
Open

Try to create iPython online notebook in google Collab #563

cyberslam opened this issue Jul 14, 2019 · 14 comments
Labels

Comments

@cyberslam
Copy link

When running under Google Colab using the following command:
"!python3 -m htm.examples.hotgym"

The following was the print-out (no error) but no plot at the end:

Parameters:
{ 'enc': {'resolution': 0.88, 'size': 700, 'sparsity': 0.02},
'sdrc_alpha': 0.1,
'sp': { 'boostStrength': 3.0,
'columnCount': 1638,
'numActiveColumnsPerInhArea': 72,
'potentialPct': 0.85,
'synPermActiveInc': 0.04,
'synPermConnected': 0.13999999999999999,
'synPermInactiveDec': 0.006},
'time': {'timeOfDay': (30, 1), 'weekend': 21},
'tm': { 'activationThreshold': 17,
'cellsPerColumn': 13,
'initialPerm': 0.21,
'maxSegmentsPerCell': 128,
'maxSynapsesPerSegment': 64,
'minThreshold': 10,
'newSynapseCount': 32,
'permanenceDec': 0.1,
'permanenceInc': 0.1}}

Encoded Input SDR( 11765 )
Sparsity Min/Mean/Std/Max 0.00543986 / 0.00552255 / 1.35811e-05 / 0.00552486
Activation Frequency Min/Mean/Std/Max 0 / 0.00552295 / 0.0317386 / 0.502847
Entropy 0.635806
Overlap Min/Mean/Std/Max 0.307692 / 0.891246 / 0.126693 / 1

Spatial Pooler Mini-Columns SDR( 1638 )
Sparsity Min/Mean/Std/Max 0.043956 / 0.0439559 / 2.08729e-07 / 0.043956
Activation Frequency Min/Mean/Std/Max 0.0170804 / 0.0439561 / 0.0182792 / 0.10066
Entropy 0.979711
Overlap Min/Mean/Std/Max 0 / 0.846308 / 0.256087 / 1
Spatial Pooler Connections:
Inputs (11765) ~> Outputs (1638) via Segments (1638)
Segments on Cell Min/Mean/Max 1 / 1 / 1
Potential Synapses on Segment Min/Mean/Max 10000 / 10000 / 10000
Connected Synapses on Segment Min/Mean/Max 86 / 395.876 / 2454
Synapses Dead (0.913949%) Saturated (0.00240562%)

Temporal Memory Cells SDR( 21294 )
Sparsity Min/Mean/Std/Max 0.00338123 / 0.0123309 / 0.013492 / 0.043956
Activation Frequency Min/Mean/Std/Max 0.00204964 / 0.012331 / 0.00762384 / 0.0594398
Entropy 0.968392
Overlap Min/Mean/Std/Max 0 / 0.609997 / 0.381052 / 1
Temporal Memory Connections:
Inputs (17335) ~> Outputs (21294) via Segments (41695)
Segments on Cell Min/Mean/Max 0 / 1.95806 / 11
Potential Synapses on Segment Min/Mean/Max 32 / 36.8715 / 64
Connected Synapses on Segment Min/Mean/Max 28 / 34.0534 / 64
Synapses Dead (0%) Saturated (0.283736%)

Predictive Error (RMS) 1 steps ahead: 18.07927468676872
Predictive Error (RMS) 5 steps ahead: 22.10117101589806
Anomaly Mean 0.2099781116136428
Anomaly Std 0.3366711792821944
<Figure size 640x480 with 2 Axes>

I had tried to put an inline comand: "%matplotlib inline"
underneath "import matplotlib.pyplot as plt", but got the same result

 import matplotlib.pyplot as plt
 %matplotlib inline 

same result: (no plot)
.....
<Figure size 640x480 with 2 Axes>

Please help!

@breznak breznak added bug Something isn't working example python not py binding, but merge py code in repo labels Jul 14, 2019
@breznak
Copy link
Member

breznak commented Jul 14, 2019

  • I think the examples don't install the plot dependencies by default, so check matplotlib is install
  • check that matplotlib is working in the google ipython notebook, I suspect it's not

@cyberslam
Copy link
Author

I had tried to import matplotlib at the beginning and also via inline versions: both were NOT effective or obtained the same result --> <Figure size 640x480 with 2 Axes>

I also had added a simple "print" (print ("Checking matplotlib here") ) statement underneath "import matplotlib.pyplot as plt" and got nothing printed!

Can anyone guide me what to do next?! Many thanks.

@breznak
Copy link
Member

breznak commented Jul 16, 2019

I'd suggest first try to run the example locally under ipython3 if it works?

this seems the plot works actually, do you need to call something like plt.show()?

But overall, this does not seem like issue in htm.core itself.

@breznak breznak added the wontfix This will not be worked on label Jul 16, 2019
@cyberslam
Copy link
Author

I tried the following in a new cell under Colab and it plotted the test chart!

Testing of matplotlib

import os
!pwd
!ls -l

import matplotlib.pyplot as plt
plt.plot(range(10))
plt.show()

and it plotted a diagonal line.

So why it won't plot in hotgym.py???

@ctrl-z-9000-times
Copy link
Collaborator

I don't why it doesn't work. It works for me on my computer. From your description it sounds like an issue with matplotlib.

Here is a stack-overflow link which might describe your issue?
https://stackoverflow.com/questions/13151514/matplotlib-plot-window-wont-appear

Maybe you could try changing the line plt.show to plt.savefig('filename.svg') and then viewing the saved image file?

@breznak
Copy link
Member

breznak commented Sep 19, 2019

@cyberslam would you describe your steps to install htm.core in google colab?
I'd love to have an online iPython notebook on Collab for htm.core! 💡

@breznak breznak changed the title No plot under Colab with the hotgym.py example Try to create iPython online notebook in google Collab Sep 19, 2019
@breznak breznak added enhancement New feature or request platform and removed bug Something isn't working python not py binding, but merge py code in repo wontfix This will not be worked on labels Sep 19, 2019
@breznak
Copy link
Member

breznak commented Sep 19, 2019

Sorry for "stealing" the issue, but with the information, I'll turn this into an optional "HTM on Collab" issue.

@cyberslam
Copy link
Author

cyberslam commented Sep 19, 2019 via email

@breznak
Copy link
Member

breznak commented Sep 19, 2019

Thanks for the message.

I was unable to install the htm.core under colab.

ok, this will be easily possible once we get to pip installable package #19

@breznak breznak mentioned this issue Sep 19, 2019
4 tasks
@htm-community htm-community deleted a comment from cyberslam Oct 8, 2019
@breznak
Copy link
Member

breznak commented Jun 8, 2020

@indy-3rdman moving the iPython online demo/notebook here

#829 (comment)

Exactly! This is pretty sweet! 💯 I'd definitely love that notebook in our examples/ and accessible directly from the readme 👍

now one thing, you have it already running in docker/binder. Does that require you to manually maintain/build the docker image, or is it built on the fly from master? Since we now can easily install releases from pip, we could use the "normal" collab/ipython notebook and run it there. What do you suggest?

@indy-3rdman
Copy link

@breznak, that was just a quick POC using the existing image, which also runs the rest_server needed for the C# examples anyway.

I might be wrong, but I think the binder related files need to be either on the root level or in the binder directory for it to work. Would that be a problem?

The docker image build is not yet fully automated, but that's on my agenda anyway. I just don't know, when I'll have the time to dig into it. Hope that's OK.

@breznak
Copy link
Member

breznak commented Jun 8, 2020

think the binder related files need to be [...] or in the binder directory for it to work

this is ok 👍

a quick POC using the existing image, which also runs the rest_server needed for the C# examples anyway.

I see, you're using that for the c# bindings (using REST API) hence you need the c++ build -> docker image, right?

  • or are those binaries included (or can we include them) in the .whl on PyPI?
  • for the python "Hellow world HTM example" running live, which I have in mind, I'd like to avoid any extra steps(docker images). And use directly install & import our release from the PyPI.
  • Would that work for your use-case too?

@indy-3rdman
Copy link

indy-3rdman commented Jun 8, 2020

@breznak, I've changed it to use the latest whl from test.pypi.org.

Binder

As you will notice, it is automatically creating a docker image from the whole repository now, including all the repository files.

This makes me wonder, whether it would make more sense to have the notebooks in a separate repository anyway.... What do you think?

@indy-3rdman
Copy link

@breznak, an example of how it would look like as separate repository: https://github.com/indy-3rdman/htm.core-jupyter

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

4 participants