invenia / ObservationDims.jl

Traits for specifying the orientation of features and observations in data
MIT License
2 stars 1 forks source link

Generalize beyond observations? #8

Open oxinabox opened 4 years ago

oxinabox commented 4 years ago

This is neat, good for finding which dimensions of a collection contain observations.

For some processes multiple dimensions are special, in different ways. But kind of similar

For example I might have some images, where each image is an observation. and I might want to do something with the channel dimension.

oxinabox commented 4 years ago

Lets consider the case:

I have say 100 images, with 3 channels RGB.

So Each image has 3 dimensions: height, width, channel so if they are stackup into a 4D array, then that is: height, width, channel, obs

The observation dimension is the 4th dimension. The content of the observation is the content of all the other dimensions.

So when say taking minibatches to train a neural net, I want to slice up the 4 dimension, the obs dimension.

But if for example I wanted to make heatmaps of colours. 1 per channel. then I care about the channel dimension. I want to do something like:

r_heat, g_heat, b_heat = sum.(eachslice(images, dim=:channel),dims=:obs)

I am not sure exactly how this fits in to this package but I know the JuliaImages ecosystem cares a lot about various axes. https://juliaimages.org/stable/indexing/

nickrobinson251 commented 4 years ago

xref https://juliaimages.org/ImageAxes.jl/stable/#Temporal-axes-1

Tokazama commented 4 years ago

I'm currently binding the JuliaImages API to NamedDims and friends here. I wonder if this package (or perhaps some other) should implement a macro for cleanly generating a lot of this code for a given dimension name. There will probably be other dimension names that end up being important (generally or just to a very specific domain) but still require a lot of the traits defined here for organising data into a consistent API.