Could running laborious code for many hours damage my mac? I'm building a deep neural network, which will take a long time to train. It's just started training and I can see that there will be roughly 7.5 hours of run-time, and my computer is making quite some noise and is heating up.

Could this damage my computer if I leave it to run? (I'll also have Caffeine switched on to stop the laptop from going to sleep.)
Well, make sure your computer is on a solid surface with space around it to permit a good flow of air.

If you can have it in a cool room instead of a warm room would help.

A computer getting warm when working hard is not a problem, but if it gets too hot is - so you should check the temperatures if possible - a fan control program is a possibility.

One other possibility may be to pause the running program and allow the computer to cool down but this may not be possible...