DarkMatterNet

Learned how to code and ran into a few speedbumps, but successfully trained a neural network on data from an astrophysical simulation. This project was my first taste of using ML in research and kickstarted my journey into computer science.

  ·  3 min read

My Research Journey #

When I was in my 2nd year of undergrad, Professor James Bullock kindly allowed me to join his cosmology research group despite my (very) limited background in physics. But what I lacked in prior coursework, I tried to make up for with curisosity. After hearing about DeepMind’s AlphaGo winning against the world Go champion, I had an idea: what if we could use neural networks to find hidden patterns in galaxy data that physicists model with expensive simulations? Thus began my journey to learn coding and the basics of ML.

THE PROBLEM: Dark matter makes up most of a galaxy’s mass, but we can’t see it directly. Astronomers have models connecting what we can see (stars, gas) to the invisible dark matter “halo” around each galaxy, but these require lots of assumptions and hand-tuning.

MY APPROACH: Train a simple neural network on simulated galaxies where we know both the visible properties AND the dark matter mass. Then see if it could predict dark matter mass from real telescope data. After some experimenting, we ended up using just three observable features: how much metal is in the gas, total stellar mass, and recent star formation rate.

THE LEARNING PROCESS: I spent months teaching myself how to code in Python and how to make neural networks with TensorFlow. I distinctly remember the feeling of excitement and then immediate disappointment when I discovered that I’d mislabeled my entire dataset (the network was predicting the wrong variable!). But after a good night’s rest and a couple bug fixes in the data pipeline, we were back in business. After tweaking all the hyperparameters and features, there were more than 200 different versions. Finally, we landed on a 3-layer network with just 18 neurons total that actually worked!

SURPRISING RESULTS: The network didn’t just get low error rates (RMSE ~ $3.77 \times 10^{10} M_\odot$, compared to typical galaxy halo masses of ~$10^{12} M_\odot$) it discovered the same galaxy-dark matter relationships that astronomers expected, without being told any physics. When I tried the same thing with multivariate regression, it failed (even predicted negative masses), highlighting the ability of neural networks to predict non-linear relationships.

THE OUTCOME: We used the trained neural network to predict dark matter masses for over 1 million real galaxies from the Sloan Digital Sky Survey. This provided researchers with a fast way to apply simulation-learned patterns to real telescope data. I got to present at group meetings, write up the findings for the Goldwater Scholarship, and learn how to tackle research problems from scratch—turning a wild idea into working code that actually advanced our understanding.

THE FUTURE: While this project was relatively simple from a technical perspective, it was an opportunity to learn how to apply machine learning in an academic enviornment. I also realized just how many layers of abstraction there were in computer science. The TensorFlow Estimator API that I had used abstracted away many of the fascinating low level details of a neural network. I realized that I wanted to learn the math and computer science fundamentals so I might one day be able to take a more theoretical deep dive. I was especially motivated by the creativity that I noticed in the brilliant physicists who supervised me. I wanted to be able to develop a deep understanding and learn how to rigorously prove things like they did. I plan to strengthen my technical background and look forward to one day being able to join the frontier of research.

Code and Technical Write-up #

GitHub Repo: DarkMatterNet