Friday, November 21, 2014

Heraldic Homecoming

In the first 22 years of my life, I never met anyone with the surname "Wills" that I wasn't related to. In fact, there seemed to be considerable resistance to the idea that "Wills" was in fact a surname, with people regularly converting it to "Willis" or "Will".  Having recently discovered there are TWO Andy Wills on the lecturing staff of Plymouth University, I looked a bit further into the university records. There are 40 current students and 11 current staff called Wills. Oh, and there's a Wills presenting local TV news, too, and two at my daughter's shcool. I have the strange feeling that I may have accidentally come home, heraldically speaking :-)

Friday, November 14, 2014

First Neural Network simulation with RCpp (R / C++ integration)

My first look into using RCpp within R to speed up neural network simulations worked out reasonably well.

Starting with as-vectorized-as-possible R code (so, presumably, fairly optimal), my test simulation (100 runs of simulating 1,500 trials of the ALCOVE model, Kruschke, 1992; multiple runs are needed as trial order affects outcome) took about 22 seconds on my 2013 Macbook Pro. Converting the time-sensitive ALCOVE parts of the R code into C++ brought the run time down to less than 3 seconds,  for an approximately 8x speed up.

These are small gains in absolute terms, but become more significant when attempting multi-parameter optimization. This often requires hundreds of iterations. In initial tests, an optimization took about 8 minutes; in plain R the same optimization would have taken over an hour.

I think I should be able to get a further 8x speed up using snowfall and a faster workstation, bringing an optimization run down to around one minute. That's for another day, though.

Thursday, November 13, 2014

Adventures in RCpp

I spent yesterday looking into using C++ within R as an environment for neural network simulations (NNs are the classic case where iteration n+1 depends on the output of iteration n, so they do not vectorize easily and hence tend to be rather slow in plain R). R's RCpp package is intended to make R and C++ integration easy. Looking promising so far, but this cartoon Charlotte Edmunds showed me is particularly apt :-)