Applied-Systems-Lab / zonoLAB

GNU General Public License v3.0
0 stars 0 forks source link

memZono - modify to more unified set operations #14

Closed jonaswagner2826 closed 7 months ago

jonaswagner2826 commented 7 months ago

Discuss:

TODO:

jonaswagner2826 commented 7 months ago

Operation layout/notes: 20240201_142501.jpg

jonaswagner2826 commented 7 months ago

20240201_150706.jpg

jonaswagner2826 commented 7 months ago

@jruths - Does this look right for syntax?

I'm not sold on it yet (I think I'd prefer:

obj1.affine(obj2, M, 'inDims', {'x_1','x_2'}, 'outDims', {'x_3, 'x_4'})

with obj2 being b if not minkowski....) but here's the current affine syntax... Image

I'm using

affine(obj,in1,in2,options)

w/ an arguments block for the defaulting of null but I think I could switch to a varargin-based one... I'm just not sure how to do the inDims/outDims varargin logic

jruths commented 7 months ago

I'm ok with obj1.affine(obj2,M, {'x_1',...,'x_n'}, {'y_1',...,'y_n'})

Since the in/out new/old labels really go with the matrix multiplication, I can see the value in having it last. I just don't like the 'inDims' and 'outDims' - the labeled arguments.

So these have acceptable syntax:

Z.affine(M)
Z.affine(M,{cell}, {cell})
Z.affine(b)
Z.affine(b,M)
Z.affine(b,M,{cell}, {cell})
Z.affine(Y)
Z.affine(Y,M)
Z.affine(Y,M,{cell}, {cell})
jonaswagner2826 commented 7 months ago

@jruths The selection of obj1.affine(obj2,M,{cell},{cell}) would end up being more like:

Z.affine([],M)
Z.affine([],M,{cell}, {cell})
Z.affine(b)
Z.affine(b,M)
Z.affine(b,M,{cell}, {cell})
Z.affine(Y)
Z.affine(Y,M)
Z.affine(Y,M,{cell}, {cell})

which I think wouldn't be great for standard usage when doing a mapping (but we could have the helper map function instead).

I'm fine eliminating the 'inDims'/'outDims', but I do wonder if we want 'all'/: or []/{} to represent all the dims in or if we want to just assume all dims if only one set of cell's are provided?

I also wonder if using a merge() or combine() (opposing the intersect()) for this operation would be better instead of affine since we're intergraging the old minSum() operation into this previously just affine operation.

jonaswagner2826 commented 7 months ago

Additional clarrification about need for the empty [] to be passed in:

jonaswagner2826 commented 7 months ago

@jruths I previously debuged the unified commands using the basic reachability example.

I have since created a version of the NN code with the unified operations and it runs (after some fixing to the inDims/outDims code) but I'm not certain what the result is supposed to be... is this correct?:

Image

Image

The layer construction could likely be simplified as well, but otherwise I've made it into these main 3 lines:

    V_{i} = NN.affine(bs{i},Ws{i},prev_xs,vs);    
    layer = intersect(layer,V_{i},sprintf('intersection_L%i',i));
    NN = NN.intersect(layer,sprintf('concat_L%i',i));

Which could technically be written as one line: NN = NN.interesect(layer.interesect(NN.affine(bs{i},Ws{i},prev_xs,vs),sprintf('intersection_L%i',i)),sprintf('concat_L%i',i));

jonaswagner2826 commented 7 months ago

@jruths I got the SLAM example working w/ the Unified operatiosn now as well...

@tannerjaykogel I'm hoping this is correct: Image

Code is essentially the same in SLAM but it could technically be written more concisely. The only real change is the specification of con labels to be distinct instead of vertcat directly: X{k} = X{k}.intersect(L{k,i},sprintf('L%i_k%i',i,k));

jruths commented 7 months ago

Awesome! This is looking great!

I agree we likely want to come up with other names for these functions since they don't do the usual operation... I'll think about what that might be....

It seems like SLAM is working ok. The neural net should look like the sinusoidal surface of the actual function... so there is some issue with that example... I haven't sat down and thought through it suuuuper carefully, but it does seem like your edits to the example are correct, so I need to check it more closely.... otherwise maybe there is some hybzono specific issue (since SLAM is working)?

jonaswagner2826 commented 7 months ago

Merged the unified branch into main... still have to go through and update comments in the memZono code and examples

jonaswagner2826 commented 7 months ago

@jruths I went back and finished the documentation/comments in the rest of memZono as requested. I did finish a few check TODOs that you left in there (mainly just a ismember() check on if dim constraints existing already and checking of inDims)... merged in now