Reproducibility Report for Saxe, McClelland & Ganguli (2013, Proceedings of Cognitive Science Society)

Author

S. Jerome Han (sjeromeh@stanford.edu)

Published

Invalid Date

Introduction

Justification for choice of study

My research interests are best described by two questions:

  1. What is it that artificial neural networks actually learn from data, and how do they do so?
  2. What other neural processes do we need to understand in order to account for human-like reasoning and problem solving in noisy, few-shot settings?

The first question is directly inspired by the work of Saxe et al., and I hope that the methods and intuitions that underlie their work will help me pursue a research program that examines the learning dynamics and knowledge representations of contemporary deep learning systems such as large language models.

The second question requires an intimate familiarity with neural network theory. In reproducing Saxe et al., I also hope to fortify my ability to understand and build upon the mathematics that underlies deep learning.

Thus, reproducing this study will both expand my methodological toolkit and provide me with the confidence to pursue a flavor of research that I currently still find a little intimidating.

Anticipated challenges

This project is inherently challenging for me because I lack a rigorous background in mathematics. No code for this project is available online, so I will have to complete the implementation based on just the paper. I am also cautious about the feasibility of condensing its intuitions into a 5 minute presentation that is accessible to other students who might also lack existing background. However, it is precisely these challenges that motivate me to take on this project, and I see no significant technical challenges that might inhibit its success.

Methods

Description of the steps required to reproduce the results

The goal of this project is to reproduce the figures presented by Saxe et al. This includes figures 2, 3, 4 and 5, with most of the work revolving around the final section of the paper, ‘The singular values and vectors of hierarchically generated data’.

To reproduce figure 2, I will recreate the toy category dataset that Saxe et al. use. This is trivial because the dataset is a simple 5x4 binary feature matrix that I can copy from the paper. I will then run SVD on this dataset and write code that turns the resulting matrices into a compelling graphic.

Figures 3, 4 and 5 require artificial data that is generated by a simple generative model of hierarchical data. I will implement this model using Python or R, following Saxe et al.’s description in the section ‘Hierarchical feature vectors from a branching diffusion process’.

Figure 3 also requires me to implement the simple one layer deep linear network that Saxe et al. use in their experiments. This will likely be achieved using PyTorch, although it may also be possible to use the keras package for R if I decide to keep everything in R.

To fully reproduce figures 3, 4 and 5 I will follow Saxe et al.’s figure and main text descriptions to apply SVD to the generated datasets and the training runs of the deep linear network. This will then be paired with a figure generating pipeline that (hopefully) precisely reproduces their original figures.

Differences from original study

It is not clear what the computing environment of the original implementation was. The implementation itself does not exist publicly. However, I do not foresee the specific computing environment mattering for reproducibility; the results here should be reproducible regardless of if I use PyTorch and Python or Keras and R.

Project Progress Check 1

Measure of success

This project might be a bit unique because Saxe et al. do not use any statistical tests in their paper. This is because it first focuses on mathematical theory before moving on to simulations that demonstrate their theory in an empirical setting. Statistical tests are therefore somewhat redundant and also difficult to formulate. Thus, my measure of success is binary for now. Specifically: can I reproduce Saxe et al.’s figures in a way that will allow me to compellingly present their paper and theory to the 251 class?

Figures 2 and 4 should be straightforward to reproduce, but an additional meta-level measure of success for me is whether I can recreate these figure in an aesthetic sense using code alone. I’ve previously tended to produce/edit more complex figures using design software, which is not the best for reproducibility, so I’d like to further develop my fancy figure coding abilities here.

Figure 3 illustrates the ‘close agreement’ between a theoretically predicted time course and several simulations. I may potentially explore how ‘close agreement’ can be better quantified, eg. using a Kolmogorov-Smirnov test, but for now I am satisfied with the intuitive measurement of ‘does the reproduced figure mostly look like the one in the original paper and align with theoretical intuitions’. Given that these are random simulations, I expect some variation but not enough to derail the point of the figure.

Figure 5 compares theoretical and simulated singular values obtained from running SVD on Saxe et al.’s hierarchically generated data. I am currently drawing a blank on what kind of statistical test may potentially be appropriate to evaluate the fit between theory and simulation, so I will leave this for a later stage (if at all). For now I am also satisfied with the intuitive visual measurement.

Pipeline progress

In a separate R file, I have an R implementation of the deep linear network that Saxe et al. use in their study. I have also recreated the toy category dataset that Saxe et al. use for figure 2. This dataset is saved in a small csv file. Finally, I have implemented the branching diffusion proces that is needed for figures 3, 4 and 5. I should now be ready to run the full analysis and begin generating preliminary figures.

Results

Data preparation

Code for all synthetic data generation can be found in ../reproduction.Rmd. I have left this code in a separate R file because it is a little long for this report.

The toy category dataset can be found in ../data/natural_dataset.csv. This dataset was copied over by hand from figure 2 in Saxe et al.

Simulations, analysis and figure generation code can also be found in ../reproduction.Rmd.

Key analysis

Figure 2 original Figure 2 reproduction

To warm up, I reproduced fig 2 from Saxe et al. by running R’s inbuilt svd function on their toy dataset. The top figure is the original figure from Saxe et al., and the bottom figure is our reproduction. These figures are visually indistinguishable, and thus tell the exact same story: SVD can decompose a hierarchically structured dataset matrix into three new matrices, introducing a new dimension (‘modes’) that provides meaning to each of these new matrices. In the object analyzer matrix, values are informative of how items covary in each mode, eg. that items can be split into ‘plants vs animals’, ‘birds vs fish’, ‘flowers vs trees’. In the feature synthesizer matrix, values are informative of which features are most typical of each mode, eg. ‘can move’ distinguishes items in the ‘plants vs animals’ mode, ‘can fly’ distinguishes items in the ‘birds vs fish’ mode, and ‘has bark’ distinguishes items in the ‘trees vs flowers’ mode. Finally the singular values matrix is informative of the importance of each of these modes for explaining variation in the original matrix, eg. the ‘plants vs animals’ mode explains more of the variation in this simple dataset than the other two modes.

Figure 3 original Figure 3 original I reproduced figure 3 by sampling from the diffusion process that they describe (10,000 features, 3 levels, flip probability of 0.1). However, the hyperparameters of the deep linear network that Saxe et al. are unknown to us; in my simulation I used a hidden layer dimension of 10 and a learning rate of 0.00025. My reproduction qualitatively matches Saxe et al., but I found it difficult to achieve the same quantitative results – although I also observed the same stage-like transitions in mode strength, and although my mode strengths asymptote at roughly the same values, my transitions happen much earlier during training than in the original paper.

Figure 4 original Figure 4 reproduction

I didn’t realise this when I was setting this project up, but figure 4 doesn’t actually need to be reproduced because it was analytically derived, ie. the authors did some maths and then manually created the figure. Nevertheless I thought that it would be a useful sanity check to ‘reproduce’ figure 4B by running SVD and extracting the object analyzer matrix from a diffusion process with 4 levels, as they describe. The original figure is calculated in the limit of large numbers of features, ie. as the number of features approaches infinity, so the reproduced figure looks more like the original figure as the number of features increases.

Figure 5 original Figure 5 reproduction

Figure 5 was challenging to reproduce. I could match the main qualitative message of the original figure, that is, that singular values are a decreasing function of hierarchy level. I could also get the theoretically calculated values to roughly match what was in the original figure. However, I ultimately could not get my simulations to match theory, which is a bit bizarre.

Discussion

Summary of Reproduction Attempt

The point of this project was to reimplement the deep linear network, SVD analysis and branching diffusion model of Saxe et al., and to then use these implementations to reproduce their figures. By reproducing their figures, the goal was to reproduce the narrative of their theory: that deep linear networks learn hierarchically structured data in stage-like transitions and in increasing levels of specificity because their training dynamics are fundamentally intertwined with the singular values of their training datasets, and because the singular values of hierchically structured training datasets are fundamentally a function of hierarchy level. Overall, this reproduction attempt was successful at qualititatively reproducing this narrative. However, some of the finer quantitative details of their figures were different from mine.

Commentary

Why was it difficult to achieve precise quantitative fits with the original paper? There are a few reasons for this. First, the original paper did not release certain details about their network and simulations – most importantly, they didn’t actually discuss the specific hyperparameters of their deep neural network. I thus had to do an informal hyperparameter sweep to try to match their results for figure 3, but even then I wasn’t totally successful. Second, there is of course some degree of randomness to these results as they are based on random simulations, so a degree of variation is to be expected. Third, some of the math is just hard to parse! Without a code release or a more detailed appendix section for me to check against, it is also possible that a minor detail of my implementation did not match that of the original authors.

As a side note, one goal that I had when picking up this project was to get better at generating figures fully in code. Yet, while I was working on figure 2 I once again found that the effort to implement specific, finicky aesthetic details in code did not seem particularly worth the time sink. Then, to my great surprise (and then delight), Andrew Saxe, the first author of this paper, spoke at one of my lab’s lab meetings and admitted when asked that he uses Adobe illustrator to create and clean up his figures. And so I promptly ditched this goal and will probably keep my attitude of being pragmatic about the time vs reproducibility tradeoff when it comes to specific aesthetic details of figures (not the contents of the figures themselves, of course!).