Tuesday, September 5, 2023

Cellular Automata

I've been interested in CA for many many years, and finally today I wrote my first code that implements the making of 'images' based on one (or possibly several at once) of 256 rules.

...

Well, before I knew it I've gone off the deep end with this stuff.  Making these things that show them 'evolve' is pretty cool, but it looks like there are only a few rules that make anything 'interesting'.  From out of nowhere I go the idea of combining rules.  So take the starting input, apply Rule 1, then use that as input to Rule 2, for input to Rule 3, etc.  I decided to stop at combining three Rules.  This appears to be very very very different than the rule combination on the wolfram website, where it's taking the final results of two different rules and applying xor, or, & and to the images to produce a result.  These results are boring.

The output of one Rule being the input to the next Rule is something I can't find any info on, which means I just haven't found anything yet (likely), or I've come up with something fairly novel.

Here's what combining Rules 86 and 112 look like:



The patterning here is subtle, but if I look at the power spectrum of each row I see this spectacular thing:



Here's the same thing with different starting points:



and the power spectrum:



details of the PS:




laksjdlaskjd

Sunday, September 3, 2023

More work towards 'visualizing' complex neural networks

I'm moving quicky into a realm where the only thing that really matters are histograms showing the ditribution of data for a particular sample.  And when it comes down to it, that's all a NN has, too!  At this point I think that's the direction that will lead to some form of 'visualization'.  I put that in quotes because it may or may not include information perceived through our eyes.  It may turn out, for instance, that hearing the network is the best way to understand it, or maybe some way of understanding it through color.  I have no idea, and that's why I'm doing it: because it's an interesting challenge that currently has everyone stumped.  Finding something that works could lead to who knows what?

If I don't find anything useful, I'm still forced to completely understand NNs in order to try to represent them in form that humans can have a chance at understanding.  This will make me better at designing and using NNs, which will help with my understanding, and round it goes.

Here's the sort of stuff I'm looking at.  These are histogram plots of the differences between the initial weights and the trained weights for one of the dense layers (with 128 connections) of the CNN I'm using for my object ID project.




The x-range is -1 to 1, and the y range is 0 to 2000.  I see no pattern.  The fact remains, however, that what I'm seeing here is the difference between a model that will just randomly choose an ID each time (and therefore choose incorrectly most of the time), and a model that will choose the correct ID every single time.

The fact that I don’t see anything (yet) is either an indication that I’m looking at it incorrectly (very likely), or the correct data isn’t being collected/measured/etc (also very likely).

I'll keep trying.

Tuesday, August 15, 2023

New Accelerometer Data, and more NN 'mind'

I've finally rigidly connected my accelerometer to my e-bike, and recording the g-force in x, y, z, and total.  The signal to noise has improved greater than a factor of two.  Here's a recording before the new connection, and then after the new connection.  You can clearly see that the signal is stronger on the bottom plot


This produces spectrograms that are much more complex.  Here's a spectrogram of the x data before the new connection:



... and then after the new connection:


I have no idea what all of those peaks are, and why they wander around so much.  I can still see the 6 Hz line (which is the tire rotation), which in this case looks pretty steady -- so those wiggly lines probably aren't correlated with speed.  Some lines go up while at the same time others go down, so I have no idea what I'm seeing.  Obviously vibrations of some sort, but I'm not sure where they're coming from, and most likely they're coming from multiple sources.

Here's the same two data sets, but looking at the y-axis data (this one surprised me a little):





I'll be collecting the acclerometer data with this configuration for the forseeable future.  The S/N is great and the spectra are baffling!

In other news, I'm starting to convince myself that grabbing 65536 points from every 128 values is the correct way to go since that the structure of the python arrays and the output model (via layer.save_model()).  There are still strange patterns, but some of those are probably residuals from the convolutions and pooling in previous layers.  Anyhow, maybe this is pretty convincing:






so, maybe this is correct.  Gotta convince myself somehow.  I'll look at the weights from the other models I have and see what they can show me.  For now, these are weights created from synthetic image training (ahem, I think).

Here's what I said on my discord server:

"An attempted visualization of one set of weights of one 'dense' layer of my fully trained multi-layer convolutional neural network.  The white borders are not part of the model: they represent the structure of the input data to this layer (in this case, 64 32x32 'images').  The weights shown here are applied to the input data (via a simple dot product), which results in a single data value as an output.  This output (along with all other outputs in this layer) is then used as input for the next layer in the network."


Monday, August 14, 2023

Looking at the 'mind' of a Neural Network

This is an ongoing project, but since I've got a nicely trained convolutional neural network sitting around, I'm trying to figure out what's going on under the hood.  No one seems to know, so I figure that's a pretty good spot for me.

First trick is to gain access to the weights stored in a trained CNN.  Once I have these, I can 'display' them in various forms to see if I can pick out any discernible patterns that might lead me to a breakthrough.  The format of the input weight file took a little while to figure out, and I'm pretty sure I'm reading it in correctly.  The output 'image' might be where I'm currently going wrong.

What bothers me about what I'm currently seeing is that there are patterns that probably shouldn't be there.  Here's a good example:




I'm pretty sure the similarities in columns is indicative of a read/write problem.  I'll figure it out, but ugh.

Sunday, August 13, 2023

Audio recording of e-bike ride

Here's a spectrogram of some of the audio of my ride on my e-bike today:



That wiggly line bothers me.  I can hear it in the recording, and it's definitely the electric motor making that sound.  The other thing is that I think either I've got the gain on the recorder too low (it's set to '20' for this data set), or having the recorder in my backpack is muffling (attenuating) the sound so much that the signal isn't very strong.  When I listen to the recording, it sounds like it's peaking, although the data doesn't indicate that.

Here's about the first four minutes of my outbound journey:


Also some accelerometer data with the recording device connected to the bike (as opposed to in my backback as it has been).  This is a short trip -- about 2.5 miles out, and 2.5 miles in.  You can clearly see the three times I hit the brakes near the beginning and end, and in the middle when I turned around.  Round trip is 789.5 seconds.


is this any better than what I already had?  Not sure yet.  I'm thinking that the device attached to the bike would have better S/N than the device flopping around in a backback.  But this is definitely different than what i've seen before.  The 6Hz line is still there, but there are other things at lower frequencies, and some interesting high freq stuff....

Also, Perseids:




USL012, and USL011.

Thursday, August 10, 2023

Random Thoughts #1

 

cool graphic -- a nice reminder about what exactly pH (and other pX) is.

... and in other news, I am now correctly (as far as I can tell) 'viewing' the weights of a trained convolutional neural network model:



Thursday, August 3, 2023

Bike accelerometer data

Instead of coming up with a way to 'correctly' attach my accelerometer onto my electric bike (which has only delayed this project), today I just set the thing recording and threw it in my backpack.

The accelerometer on my phone collects data at about 203Hz, so the highest frequency it can deal with is about 100Hz.

Technical problems failed to record my outbound ride, but my inbound ride was recorded.  Here's the data:



... and here's the spectrogram (using a 256 sampling window in a 4096 pad):




spectral range (left to right) goes from 0 to about 100 Hz.  Temporal range is about 900 seconds, doing from top to bottom.

That bright white wiggly line is about 6 Hz.  This corresponds to the rotational frequency of the tires if traveling about 28 mph -- which I was!  The line is wiggly because I'm contantly slowing down and speeding up.

Check out the harmonics!

Pretty decent S/N -- I think I can work with this...

Here's a plot of the average spectrogram, which is just the sum of each row from the image above.  The peak is about 5.84 Hz, which with 26 inch wheels works out to an average speed of 27.1 mph.  I can't account for those other smaller peaks to the left at about 4 Hz and 1.6 Hz.