Because I essentially got it wrong in the last post … turns out that a fully connected network is, generally, not a great idea for image processing and that partial connections – through “convolution layers” are likely to be more efficient.
And my practical experience backs this up: my first NN did, in effect, have two convolution layers (or filters), although somewhat eccentrically designed as 100 x 1 and 1 x 100 filters. And this network performs better than the single hidden layer fully connected alternative. That may just be because it takes an age to train the fully connected network and converge of the error levels towards a low number is just taking for ever (a convolution layers has many fewer connections and so can be trained much faster).
Cheap and accessible books on neural nets are not easy to find – so I bought “Practical Neural Network Recipes in C++” as a second-hand book on Amazon (link). According to Google Scholar this book – though now 24 years old – has over 2,000 citations, so it ought to be good, right?
Well, the C++ is really just C with a few simple classes – lots of pointers and not an STL class to be seen (but then I can hardly blame author Timothy Masters for not seeing into the future). The formatting is awful – it seems nobody even thought that you could put the source into a different font from the words. But, yes, it works.
Essentially I used it – though I had to get additional help to understand back propagation as the book’s explanation is garbled, mixing up summed outputs and outputs from activation functions for instance – to build a simple neural network which worked, after a fashion.
(In fact I didn’t build a fully connected network, because the book didn’t say – anywhere that I could see, anyway – that you should. I have rectified that now and my network is much slower at learning but does seem, generally, to be delivering better results.)
But it seems that 24 years is a long time in the world of neural nets. I now know that “deep learning” isn’t just (or only) a faddish way of referring to neural networks, but a reflection of the idea that deep nets (i.e., with multiple hidden layers) are generally thought to be the best option, certainly for image classification tasks. Timothy Masters’s book essentially describes additional layers as a waste of computing resources: certainly anything above two hidden layers is expressly dismissed.
Luckily I have access to an electronic library and so haven’t had to buy a book like “Guide to Convolutional Neural Networks” (Amazon link) – but I have found it invaluable in learning what I need to do. But it’s complicated: if I build many different convolutional layers into my code the network will be slow(er) – and it will be time to break out the threads and go parallel. But now I have fallen into this rabbit hole, I might as well go further.
I am working on a project to see whether, using various “deep learning” methods, it is possible to take a photograph of some musical notation and play it back. (I was inspired to do this by having a copy of 1955’s Labour Party Songbook and wondering what many of the songs sounded like.)
The first task is to identify which parts of the page contain musical notation and I have been working with a training set built from pictures of music chopped into 100 x 100 pixel blocks – each is labelled as containing or not containing musical notation and the network is trained, using back propagation, to attempt to recognise these segments automatically.
Now I have tested it for the first time and the results are interesting – but a bit disappointing. In this image all that is plotted is the neural net’s output: the redder the image, the higher the output from the net’s single output neuron:
It’s a bit of a mystery to me as to why you can see the staves and notes in this sort of shadowy form: as that means the network is rejecting them as musical notation even as it does highlight the regions where they are found as the best places to look.
To make it all a bit clearer, here are the results with the blue/green pixels of the original image unchanged and the red pixels set on the strength of the network’s output:
It seems clear the network is, more or less, detecting where there is writing on the page – though with some bias towards musical staves.
I’m not too disappointed. My approach – based on stuff I read in a book almost 25 years old – was probably a bit naïve in any case. I came across a much more recent and what looks to be much more relevant text yesterday and that’s what I will be reading in the next few days.
Neural networks have fascinated me for a long time, though I’ve never had much luck applying them.
Back in the early and mid 1990s the UK’s trade and industry department ran a public promotional programme to industry about NNs and I signed up, I even bought a book about how to build them in C++ (and I read it, though I have to confess my understanding was partial).
My dream then was to apply the idea to politics: as a more effective way of concentrating resources on key voters. My insight was that, when out doing what political parties then called “canvassing” and now – largely for less than fully honest legal reasons as far as I can see – call “voter ID” (in electoral law “canvassing” i.e., seeking to persuade someone to vote one way is more highly regulated than simply “identifying” how they intend to vote) you could quite often tell how someone would respond to you even before they opened the door. There was some quality that told you, you were about to knock on a Labour voter’s door.
I still don’t know what that quality is – and after the recent election I’m not sure the insight applies any more any way – but the point was that if you could take a mass of data and have the NN find the function for you, then you could improve your chances of getting to your potential support and so on…
But I never wrote any code and NNs seemed to go out of fashion.
Now, renamed “machine learning”, they are back in fashion in a big way and my interest has been revived. But I am not trying to write any code that will work for politics.
Instead I am exploring whether I can write any code that will look at a music score and play it back. (This probably a silly idea as a start NN project, as music is not easy to decipher in any way as far as I can see).
The first task is to actually identify which bits of scribbling on the page are musical notation at all. And I have written some code to build a training set for that – here. It might well be of use to you if you need to mark bits of a JPEG as “good” or “bad” for some other purpose, so please do get in touch if you need some help with that.
I have not yet had any volunteers, though the flurry of online interest did get me to complete the first draft – so alpha testers still needed.
In the meantime, I have also published the version of Conway’s Game of Life the text is based around. It’s a slightly unusual implementation in that the surface of the game is, in effect, spherical in effect a torus – i.e. the edges are effectively a feature of the projection of the surface but left joins to right, top to bottom and so on.
Update: Been pointed out to me that this isn’t a sphere but a torus, and so I have updated the copy.
Three years ago I had great fun teaching some primary school children how to use Scratch and take their first steps towards being computer programmers of the future.
At the time there was a lot of optimism about changes to the English curriculum and a return to a more rigorous teaching of computing in schools.
Today, though, there is a pretty predictable warning that things aren’t going to plan – like so much else in the last seven years good intentions were not backed up by the money needed to make the policy really work.
Back then I decided I was going to write a “book” on how to code – my principal audience being teachers who suddenly found themselves with the requirement to teaching basic coding … but had a change of job, couldn’t continue the teaching and nothing much happened.
But, having had another, err, change of job (to currently no job – have a look here if you want to hire me), I’m now determined to finish it and so I am also looking for anyone willing to read it through.
I don’t intend to charge for it, so it’s not a commercial operation, but I would be interested in hearing from anybody who has an interest in learning to code/learning more about computing but who is not an experienced programmer – crudely put, if you think the “book” stinks then I probably won’t make much more of an effort with it, if you think it is good or getting there then I’ll keep working on it, trying to make it e-reader compatible and so on.
Let me know in the comments or directly: adrianmcmenamin at Google’s email service.
You know how it is … you go for a run and then lying in the bath you read a New Scientist article about Dark Energy and you think of two crazy ideas which you hope some respectable scientist will at least have stuck a paper on arXiv on, so you can at least say “I thought of that in the bath and it might even be right…”
Except that you can find no such papers, so you are reduced to looking like the crackpot you are by posing them here:
Inertial mass is caused by the gravitational field of a certain amount of matter that has been trapped in collapsed dimensions. Those dimensions are always the same distance away from any given point, so inertial mass is the same anywhere in the universe.
Dark energy is caused by the ‘evaporation’ via Hawking radiation or similar of our universe (sadly I am not the first to have thought of this particular piece of crack-pottery, so I won’t be collecting a Nobel prize for it). Further searching reveals there is even an arXiv paper on such an idea after all.