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.
No comments:
Post a Comment