Replies

This profile is from a federated server and may be incomplete. Browse more on the original instance.

jonny, to python
@jonny@neuromatch.social avatar

Here's an ~ official ~ release announcement for

repo: https://github.com/p2p-ld/numpydantic
docs: https://numpydantic.readthedocs.io

Problems: @pydantic is great for modeling data!! but at the moment it doesn't support array data out of the box. Often array shape and dtype are as important as whether something is an array at all, but there isn't a good way to specify and validate that with the Python type system. Many data formats and standards couple their implementation very tightly with their schema, making them less flexible, less interoperable, and more difficult to maintain than they could be. The existing tools for parameterized array types like nptyping and jaxtyping tie their annotations to a specific array library, rather than allowing array specifications that can be abstract across implementations.

numpydantic is a super small, few-dep, and well-tested package that provides generic array annotations for pydantic models. Specify an array along with its shape and dtype and then use that model with any array library you'd like! Extending support for new array libraries is just subclassing - no PRs or monkeypatching needed. The type has some magic under the hood that uses pydantic validators to give a uniform array interface to things that don't usually behave like arrays - pass a path to a video file, that's an array. pass a path to an HDF5 file and a nested array within it, that's an array. We take advantage of the rest of pydantic's features too, including generating rich JSON schema and smart array dumping.

This is a standalone part of my work with @linkml arrays and rearchitecting neurobio data formats like NWB to be dead simple to use and extend, integrating with the tools you already use and across the experimental process - specify your data in a simple yaml format, and get back high quality data modeling code that is standards-compliant out of the box and can be used with arbitrary backends. One step towards the wild exuberance of FAIR data that is just as comfortable in the scattered scripts of real experimental work as it is in carefully curated archives and high performance computing clusters. Longer term I'm trying to abstract away data store implementations to bring content-addressed p2p data stores right into the python interpreter as simply as if something was born in local memory.

plenty of todos, but hope ya like it.

[Further demonstration of validation and array expression, where a Union of NDArray specifications can specify a more complex data type - eg. an image that can be any shape in x and y, an RGB image, or a specific resolution of a video, each with independently checked dtypes] For example, to specify a very special type of image that can either be a 2D float array where the axes can be any size, or a 3D uint8 array where the third axis must be size 3 a 1080p video from typing import Union from pydantic import BaseModel import numpy as np from numpydantic import NDArray, Shape class Image(BaseModel): array: Union[ NDArray[Shape["* x, * y"], float], NDArray[Shape["* x, * y, 3 rgb"], np.uint8], NDArray[Shape["* t, 1080 y, 1920 x, 3 rgb"], np.uint8] ] And then use that as a transparent interface to your favorite array library! Interfaces Numpy The Coca-Cola of array libraries import numpy as np # works frame_gray = Image(array=np.ones((1280, 720), dtype=float)) frame_rgb = Image(array=np.ones((1280, 720, 3), dtype=np.uint8)) # fails wrong_n_dimensions = Image(array=np.ones((1280,), dtype=float)) wrong_shape = Image(array=np.ones((1280,720,10), dtype=np.uint8)) # shapes and types are checked together, so this also fails wrong_shape_dtype_combo = Image(array=np.ones((1280, 720, 3), dtype=float))
[Demonstration of usage outside of pydantic as just a normal python type - you can validate an array against a specification by checking it the array is an instance of the array specification type] And use the NDArray type annotation like a regular type outside of pydantic – eg. to validate an array anywhere, use isinstance: array_type = NDArray[Shape["1, 2, 3"], int] isinstance(np.zeros((1,2,3), dtype=int), array_type) # True isinstance(zarr.zeros((1,2,3), dtype=int), array_type) # True isinstance(np.zeros((4,5,6), dtype=int), array_type) # False isinstance(np.zeros((1,2,3), dtype=float), array_type) # False
[Demonstration of JSON schema generation using the sort of odd case of an array with a specific dtype but an arbitrary shape. It has to use a recursive JSON schema definition, where the items of a given JSON array can either be the innermost dtype or another instance of that same array. Since JSON Schema doesn't support extended dtypes like 8-bit integers, we encode that information as maximum and minimum constraints on the

neuralreckoning,
@neuralreckoning@neuromatch.social avatar

@jonny solidarity! And good luck.

neuralreckoning, to random
@neuralreckoning@neuromatch.social avatar

OK, let's try something new. I'm not well connected because I'm bad at in person networking, and this is compounded by my decision to stop flying to conferences. So, can I use mastodon to find potential experimental colleagues who would like to work together?

Ideally for me, this would be people in Europe so I can visit by train, but it's not essential. I have some ideas for interesting projects and grant applications, and I'd love to develop those into concrete projects in close participation with experimental colleagues.

One of the main themes I'm interested in is how we can relate various neural mechanisms (e.g. inhibition, recurrence, nonlinear responses) to functions, using computational modelling to ask 'what if' questions that couldn't be answered by experiments alone.

I'm also interested in thinking about how we can use "information bottleneck" ideas to think more clearly about what computations networks of neurons are doing, going the next step beyond representing information to computing / discarding information.

A big question I'd like to answer is to find out how different brain regions work together in such a flexible and scalable way.

A technique I'm very excited about at the moment is using modern ML algorithms to train spiking neural networks at cognitively challenging tasks, making them directly comparable to both psychophysical and electrophysiological data.

Part of that could involve building in new mechanisms, like dendritic structure or neuromodulators into those networks and allowing the trained networks to make use of them in the best way possible.

I'd also love to build jointly motivated experimental and theoretical/synthetic datasets to test models against.

If any of that sounds interesting to you, take a look at some of my recent papers and get in touch. I'd love to hear from you.

http://neural-reckoning.org/publications.html

neuralreckoning,
@neuralreckoning@neuromatch.social avatar

@jonny @mschottdorf I'll definitely be doing some stuff like what you suggest over the next few years. Will be in touch!

susanleemburg, to random
@susanleemburg@neuromatch.social avatar

OMG but I hate Python.

I just want to run some spike detection code I made a while ago.
Instead of spikes I get a weird error. So now I need to update package 1, which requires updating package 2, 3, 4, 7, and 28, which in turn want a newer version of python (except package 9 which refuses to work now of course), so I also need to reinstall anaconda completely (fuck knows why the upgrade button never works)...
And of course none of that actually runs, so I need to figure out how to make things go in a docker container that is in turn wrapped in whatever the hell a singularity is?

neuralreckoning,
@neuralreckoning@neuromatch.social avatar

@jonny @elduvelle @susanleemburg I had the opposite feeling, that everything with Matlab for me was always a struggle and that it was a joy to move over to Python for that reason. However, it's definitely the case that the Python ecosystem has gotten worse in terms of dependency hell than it used to be. I do wonder if the easy availability of virtual environments and docker etc. have made it easier to be lazy about backwards compatibility when developing packages. We test @briansimulator on a huge array of combinations of different versions of python, operating system, etc. to guard against this and it's not that difficult to set up a continuous integration infrastructure to do this using GitHub actions. I wish more people would.

neuralreckoning,
@neuralreckoning@neuromatch.social avatar

@susanleemburg @jonny @elduvelle @briansimulator I don't think it's your fault, it's the lack of backwards compatibility in packages. It should just work.

neuralreckoning,
@neuralreckoning@neuromatch.social avatar

@jonny @susanleemburg @elduvelle @briansimulator I don't agree that enforcing backwards compatibility is a bad idea. Otherwise you get the problem that package X requires a particular range of versions of Y, but package Z requires a non overlapping range of versions of Y meaning that X and Z can't be used together. Python ecosystem rife with this sort of problem. Backwards compatibility eliminates this problem. Just upgrade everything.

neuralreckoning,
@neuralreckoning@neuromatch.social avatar

@jonny I'll agree with there being times when it's necessary. We broke compatibility once with Brian in it's 17 years so far, and that seems like a reasonable frequency. But we also made a new package name so actually no breaks in compatibility. My worry is when breaks are frequent enough that you can't install two packages because of non overlapping requirements. This happened to me more than once, so it's a real problem.

neuralreckoning, to random
@neuralreckoning@neuromatch.social avatar

UX peeve. Lamps that you have to tap repeatedly to adjust brightness so that if you want it to get less bright you have to cycle through more bright first. Bring back clunky analogue switches. Touch interface is bad for everything except a phone.

neuralreckoning,
@neuralreckoning@neuromatch.social avatar

@elduvelle how do these things get made? By people who don't actually use stuff?

neuralreckoning,
@neuralreckoning@neuromatch.social avatar

@BorisBarbour @elduvelle is there that much difference between a touch and physical switch?

neuralreckoning,
@neuralreckoning@neuromatch.social avatar

@BorisBarbour @elduvelle sigh. Enshittification not just for software.

neuralreckoning, to science
@neuralreckoning@neuromatch.social avatar

Thought about hypothesis testing as an approach to doing science. Not sure if new, would be interested if it's already been discussed. Basically, hypothesis testing is inefficient because you can only get 1 bit of information per experiment at most.

In practice, much less on average. If the hypothesis is not rejected you get close to 0 bits, and if it is rejected it's not even 1 bit because there's a chance the experiment is wrong.

One way to think about this is error signals. In machine learning we do much better if we can have a gradient than just a correct/false signal. How do you design science to maximise the information content of the error signal?

In modelling I think you can partly do that by conducting detailed parameters sweeps and model comparisons. More generally, I think you want to maximise the gain in "understanding" the model behaviour, in some sense.

This is very different to using a model to fit existing data (0 bits per study) or make a prediction (at most 1 bit per model+experiment). I think it might be more compatible with thinking of modelling as conceptual play.

I feel like both experimentalists and modellers do this when given the freedom to do so, but when they impose a particular philosophy of hypothesis testing on each other (grant and publication review), this gets lost.

Incidentally this is also exactly the problem with our traditional publication system that only gives you 1 bit of information about a paper (that it was accepted), rather than giving a richer, open system of peer feedback.

neuralreckoning,
@neuralreckoning@neuromatch.social avatar

@jonny well the first one seems to be arguing for longer spent before doing a hypothesis test so arguably that's an even lower information rate overall. 😉 The second one seems closer but I haven't read past first page yet. Does it talk about how we could have a richer error signal?

neuralreckoning,
@neuralreckoning@neuromatch.social avatar

@jonny will definitely read, looked interesting and that's a strong recommendation.I think my point is maybe something like: if the real value is not the output of the experiment but the exploratory work, shouldn't we be teaching this and valuing it more highly rather than denigrating it as fishing trips and rejecting grants on this basis?

neuralreckoning,
@neuralreckoning@neuromatch.social avatar

@jonny I don't think it's just the publishing system but it's surely an unhealthy combination!

neuralreckoning,
@neuralreckoning@neuromatch.social avatar

@jonny right sorry that's what I meant. Just so used to railing against the publishing system that I typed it without thinking. 😉

elduvelle, (edited ) to random
@elduvelle@neuromatch.social avatar

still asking $60 for 1 year of 6Gb… 😭 @zotero I love you all but it’s 2024 now, maybe you could either reduce the price or increase what we get for it?

Edit: not even 60… just SIX

neuralreckoning,
@neuralreckoning@neuromatch.social avatar

@elduvelle @zotero I think of it as a way to support development and sustainability. Happy to pay since I can, but also happy for others to use solutions like webdav etc.

tiago, to python
@tiago@social.skewed.de avatar

Good news everyone! A new version of :gt: graph-tool is just out! @graph_tool

https://graph-tool.skewed.de

:gt: @graph_tool is a comprehensive and efficient :python: Python library to work with networks, including structural, dynamical and statistical algorithms, as well as visualization.

It uses :cpp: C++ under the hood for the heavy lifting, making it quite fast.

This version includes new features, bug fixes, and improved documentation: https://graph-tool.skewed.de/static/doc/index.html

One of the new features is scalable and principled network reconstruction: https://graph-tool.skewed.de/static/doc/demos/reconstruction_indirect/reconstruction.html

Single line installation:

Anaconda ⤵️
conda create --name gt -c conda-forge graph-tool

Homebrew ⤵️
brew install graph-tool

Debian/Ubuntu ⤵️
apt-get install python3-graph-tool

Gentoo ⤵️
emerge graph-tool

Docker ⤵️
docker pull tiagopeixoto/graph-tool

You can also play it with in colab: https://colab.research.google.com/github/count0/colab-gt/blob/master/colab-gt.ipynb

@networkscience
@datascience
@python

image/png
image/png

neuralreckoning,
@neuralreckoning@neuromatch.social avatar

@tiago @graph_tool @networkscience @datascience @python looks cool! Have you seen our stochastic gradient descent layout algorithm? Fast and high quality with c++ code you can help yourself to.

https://github.com/jxz12/s_gd2

  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • rosin
  • mdbf
  • tacticalgear
  • osvaldo12
  • InstantRegret
  • DreamBathrooms
  • modclub
  • magazineikmin
  • thenastyranch
  • khanakhh
  • Youngstown
  • slotface
  • kavyap
  • JUstTest
  • ethstaker
  • tester
  • GTA5RPClips
  • Durango
  • normalnudes
  • cubers
  • ngwrru68w68
  • everett
  • provamag3
  • cisconetworking
  • anitta
  • Leos
  • lostlight
  • All magazines