Galaxy augmentation explorer

Does turning the training images help a CNN recognise new galaxies? Two copies of one small image classifier are trained, one on randomly rotated images, and tested on the same 3,544 galaxies.

Below: where the data and the method come from, then the settings and the split stored with the saved results that every chart on this page reads.

Data source. Galaxy10 DECaLS — centred 64 × 64 × 3 colour images in ten human morphology classes. Detailed dataset provenance and usage conditions are on the Dataset page.

Notebook lineage

Author
The PC5251 course notebook Galaxy2.ipynb; this demo repeats its comparison.
Source / context
PC5251 teaching demo: it repeats the notebook's own augmentation comparison on the full ten-class dataset.
Notebook
Galaxy2.ipynb

What the saved results record

Each row is one setting or quantity stored with the saved results. The Produced by column names the stage of the original pipeline that produced it.

Property Recorded value Produced by

In the Embeddings row, a galaxy's embedding is the 32 numbers the network's last hidden layer produces for it, just before the ten class scores.

The fixed split, class by class
PartGalaxiesShare0123456789What it is for
Train12,41570.0%7621,2951,8571,4432261,3931,2841,8329901,333fit weights; rotation applies only here
Validation1,77710.0%10218826321231227177248152177inspect learning during training
Test3,54420.0%21737052537277423368548281363one untouched final comparison

Column headings 0–9 are the class indices used throughout this page; the class list in the Design matrix section gives their names.

What a row and a column are here

Size of the data table (design matrix X) given to the CNN

—

One row is one galaxy image, 64 × 64 × 3 (pixels × pixels × colour channels), laid out as a single line of numbers. The class label is kept separately.

17,736
Galaxies
10
Classes in y
12,288
Values per image
42
Split seed

How a row is built

  • Each image arrives as 64 × 64 pixels in 3 colour channels — 12,288 values in all.
  • Those values are the row, kept on the original 0–255 brightness scale as float32 numbers; nothing is standardised, centred or rescaled.
  • The morphology class is stored in a separate target vector y with 10 possible values, never as a column of X.
  • The three parts of the split are cut once, at seed 42, before either model exists, so both models are scored on the same 3,544 test rows.

The matrix itself

Row X[i,:] is one complete galaxy image flattened to pixel-channel values; column X[:,j] is one pixel-channel read down every galaxy; their intersection x_ij is one 0–255 channel value. The target y is a separate vector of human morphology labels — it is never part of X.

The highlighted row is the selected galaxy (choose one under “What does each galaxy class look like?”). Its 12,288 values form one row of X; its morphology class is stored separately in y, as class 2 · Round smooth.

How to read this panel. It is a sketch of the shape of X and of where the selected galaxy's row sits in it. The cell shading is a fixed pattern, not the galaxy's pixel values; the galaxy's real pixels appear in the galaxy images elsewhere on this page. Hover over a band to see which rows it covers.

The ten target classes are imbalanced

number of galaxies of each class in the complete dataset

0 · Disturbed1,081
1 · Merging1,853
2 · Round smooth2,645
3 · In-between round smooth2,027
4 · Cigar-shaped smooth334
5 · Barred spiral2,043
6 · Unbarred tight spiral1,829
7 · Unbarred loose spiral2,628
8 · Edge-on without bulge1,423
9 · Edge-on with bulge1,873
The same counts as numbers, by part of the split
#ClassIn the datasetTrainValidationTest
0Disturbed1,081762102217
1Merging1,8531,295188370
2Round smooth2,6451,857263525
3In-between round smooth2,0271,443212372
4Cigar-shaped smooth3342263177
5Barred spiral2,0431,393227423
6Unbarred tight spiral1,8291,284177368
7Unbarred loose spiral2,6281,832248548
8Edge-on without bulge1,423990152281
9Edge-on with bulge1,8731,333177363

One fixed split, made once

the notebook's two train_test_split calls, at the recorded seed

Train · 12,415 (70.0%)fit weights; rotation only here
Validation · 1,777 (10.0%)inspect learning during training
Test · 3,544 (20.0%)one untouched final comparison

One split for both models. It is cut once at seed 42 and reused by both models, so their test scores are measured on the same galaxies. Rotation is applied only to training mini-batches.

What does each galaxy class look like?

one real stored example per class · select one to follow it through the workflow

Each image is a real test galaxy from the stored cases. Click one to select it: the highlighted matrix row, the two rotation images, the ring on the embedding map and the two models' predictions in the Evaluation section all switch to that galaxy.

Transformation — original views and rotated views

What this step does. A galaxy's shape class does not depend on which way its picture is turned. So one model is trained on the training images as supplied, and a second on copies turned by a new random angle each time they are used. If the idea holds, the second model should do better on galaxies it has never seen. Validation and test images are the same for both models and are never rotated.

No augmentationUse every training image in its supplied orientation.
Training rowRead the supplied 64 × 64 × 3 image.
No spatial changeThe same orientation is seen whenever this row is sampled.
Label preservedThe original class label y is the training target.
Rotation augmentationTurn each training image by a new uniform random angle from -90° to +90° every epoch.
Same training rowStart from the same unique galaxy.
Random rotationA new view is generated inside the training loop.
Same labelRotation changes orientation, not morphology.

How to read this figure. Both models train on the same galaxies; rotation adds new orientations, not new galaxies. The images show the selected galaxy, which is a test image, turned by the angle stored with it to illustrate the operation. Test images were never rotated in training or evaluation.

Modelling & training — two fresh copies of one architecture

Both models use the network drawn below. Its three convolution blocks learn spatial features of the image; three dense layers (64 → 32 → 10) then turn those features into one score per class. As in the notebook, the model trained with rotation starts from its own random weights and has its own batch order, dropout masks and rotation angles. The 32 values from the last hidden layer are the embedding used for the maps further down.

64×64×3 image 
Conv 8BatchNorm · ReLU · MaxPool · Dropout
Conv 16BatchNorm · ReLU · MaxPool · Dropout
Conv 32BatchNorm · ReLU · MaxPool · Dropout
Flatten 2,048 
Dense 64 → Dense 32 → 10 logits 
Softmax probabilities 

Galaxy2 three-block CNN · 140,074 trainable parameters · Adam · cross-entropy

The two stored training histories

Each chart shows one model's accuracy after every epoch (one pass through the training images): solid for training images, dashed for validation images. Drag the epoch slider below, or click a curve, to read both models at one epoch; hover over a curve for exact values.

No augmentation

same supplied views
train 62.6%validation 43.5%train–validation gap +19.1%

Rotation augmentation

training views change each epoch
train 55.1%validation 55.3%train–validation gap −0.2%
100
Both training histories as numbers at the chosen epoch
Stored quantity at epoch 100No augmentationRotation augmentation
Training loss1.03871.2597
Training accuracy62.62%55.06%
Validation loss1.59001.2157
Validation accuracy43.50%55.26%
Seconds in this epoch17.1422.55

The learned embedding before the final classifier

Just before it gives its ten class scores, each model describes a galaxy with 32 numbers, the output of its last hidden layer. These numbers are the model's embedding of that galaxy: galaxies the model treats as alike get similar numbers. PCA, t-SNE and UMAP each squeeze the 32 numbers into two, so that all 3,544 test galaxies can be drawn as dots; each method was run separately for each model. Choose a model, a method and its parameters below, and click a dot to see that galaxy's image.

1 · Model
2 · Method
3 · Parameters
Select a point

Click a point in the embedding to inspect its original test image.

0 · Disturbed1 · Merging2 · Round smooth3 · In-between round smooth4 · Cigar-shaped smooth5 · Barred spiral6 · Unbarred tight spiral7 · Unbarred loose spiral8 · Edge-on without bulge9 · Edge-on with bulge

Rotation augmentation · t-SNE · perplexity = 15 · learning_rate = auto. Local trustworthiness@10 is 0.995. Truth-label silhouette is -0.043 (higher is more separated; a negative value means overlap). Nonlinear local-neighbour view. Cluster spacing, size and axis values are not globally meaningful. Colour is the human-assigned class; the ring marks the selected galaxy.

How to read the axes. Each choice of model, method and parameters shows a different stored map of the same test galaxies. In t-SNE and UMAP maps the axes have arbitrary units: distances can be compared within one map, but not between two maps.

Every stored map as numbers, both models
MethodParametersModeltrustworthiness@10silhouette (truth)2-component variance
PCAn_components = 2No augmentation0.913-0.09666.2%
PCAn_components = 2Rotation augmentation0.911-0.05963.9%
t-SNEperplexity = 15 · learning_rate = autoNo augmentation0.989-0.081not defined
t-SNEperplexity = 15 · learning_rate = autoRotation augmentation0.995-0.043not defined
t-SNEperplexity = 30 · learning_rate = autoNo augmentation0.989-0.084not defined
t-SNEperplexity = 30 · learning_rate = autoRotation augmentation0.995-0.043not defined
t-SNEperplexity = 50 · learning_rate = autoNo augmentation0.988-0.091not defined
t-SNEperplexity = 50 · learning_rate = autoRotation augmentation0.995-0.042not defined
UMAPn_neighbors = 15 · min_dist = 0.05No augmentation0.976-0.095not defined
UMAPn_neighbors = 15 · min_dist = 0.05Rotation augmentation0.987-0.069not defined
UMAPn_neighbors = 15 · min_dist = 0.4No augmentation0.948-0.094not defined
UMAPn_neighbors = 15 · min_dist = 0.4Rotation augmentation0.959-0.054not defined
UMAPn_neighbors = 60 · min_dist = 0.05No augmentation0.967-0.096not defined
UMAPn_neighbors = 60 · min_dist = 0.05Rotation augmentation0.980-0.059not defined
UMAPn_neighbors = 60 · min_dist = 0.4No augmentation0.942-0.094not defined
UMAPn_neighbors = 60 · min_dist = 0.4Rotation augmentation0.955-0.050not defined

Negative silhouette values mean the ten human-assigned classes overlap in the learned 2-D view, even where a nonlinear method makes local neighbourhoods easier to see.

Evaluation — the same untouched test set, both models

Both models are scored on the same 3,544 test galaxies, which neither saw in training and which are never rotated. The comparison is made four ways: headline metrics, confusion matrices (where each class's galaxies end up), reliability curves (whether confidence matches accuracy), and the same real test galaxies side by side.

Metric on the untouched test setNo augmentationRotation augmentationChange
Test accuracy44.61%55.25%+10.64%
Weighted precision57.06%59.62%+2.56%
Weighted recall44.61%55.25%+10.64%
Weighted F140.74%50.53%+9.80%
Expected calibration error (lower is better)10.05%3.09%−6.96%

Change is the Rotation augmentation value minus the No augmentation value, in percentage points. These two models come from the independent-start run: each started from its own random weights and saw its own random batch order, as in the notebook.

Confusion matrices

row-normalized · rows truth, columns prediction

No augmentation

Rotation augmentation

0 % of the true class100 % of the true class

Each row is one true class; its cells show where the model sent those galaxies, as a share of the row. Darker cells on the diagonal mean more galaxies put in their true class. Hover over a cell for its share and count.

Both matrices as raw counts
No augmentation — raw counts, rows are the true class
True class→ 0→ 1→ 2→ 3→ 4→ 5→ 6→ 7→ 8→ 9row total
0 · Disturbed18163520107543217
1 · Merging61088511311042311370
2 · Round smooth0250113010800525
3 · In-between round smooth32163194000901372
4 · Cigar-shaped smooth1156310040277
5 · Barred spiral4691104060614723423
6 · Unbarred tight spiral0210342063017942368
7 · Unbarred loose spiral459893073319145548
8 · Edge-on without bulge331143002716862281
9 · Edge-on with bulge0914136210118182363
Rotation augmentation — raw counts, rows are the true class
True class→ 0→ 1→ 2→ 3→ 4→ 5→ 6→ 7→ 8→ 9row total
0 · Disturbed1154539111081717217
1 · Merging11875140020017945370
2 · Round smooth012479601121500525
3 · In-between round smooth0101152200301707372
4 · Cigar-shaped smooth00423610513777
5 · Barred spiral2535390254068812423
6 · Unbarred tight spiral0339611701512266368
7 · Unbarred loose spiral3133948213712642417548
8 · Edge-on without bulge1111000519874281
9 · Edge-on with bulge13713020211324363

Reliability curves

confidence versus actual accuracy on the test set

No augmentation

Rotation augmentation

Test predictions are grouped by the model's confidence; each point plots a group's average confidence against the share it got right. On the diagonal, confidence matches accuracy; below it, the model is overconfident. Expected calibration error (ECE) sums up the gap; lower is better. Hover over a point for its numbers.

The bins as numbers — including the empty ones
Confidence binNo augmentationRotation augmentation
nconfidenceaccuracynconfidenceaccuracy
0.0000 – 0.06670——0——
0.0667 – 0.13330——0——
0.1333 – 0.20001018.71%0.00%1318.94%0.00%
0.2000 – 0.266712824.27%28.91%15023.87%28.00%
0.2667 – 0.333336930.32%30.35%37130.31%32.88%
0.3333 – 0.400045436.71%30.62%48436.73%38.84%
0.4000 – 0.466752243.36%34.67%53543.22%42.06%
0.4667 – 0.533348649.75%39.71%45949.79%52.51%
0.5333 – 0.600034656.46%43.35%33356.51%59.46%
0.6000 – 0.666727662.93%45.65%29263.26%66.78%
0.6667 – 0.733324269.95%50.00%27569.68%68.73%
0.7333 – 0.800019376.41%54.40%27476.58%79.56%
0.8000 – 0.866718483.10%66.30%20683.26%92.23%
0.8667 – 0.933322790.16%87.67%13889.60%98.55%
0.9333 – 1.000010795.55%89.72%1494.84%100.00%

2 of the 15 bins are empty for both models: no prediction fell in them, so they show a dash and the curves skip them.

The same real test galaxy, both predictions

Showing 129 of the 129 stored test galaxies (out of 3,544). Filter them with the buttons, then click a tile to compare the two models' predictions.

Human label: 2 · Round smooth
held-out source row 3,013

No augmentation

Prediction: 1 · Merging

Merging52.3%
Truth · Round30.6%
In-between12.7%

Rotation augmentation

Prediction: 2 · Round smooth

Truth · Round58.5%
Merging16.5%
In-between12.8%

Rotation augmentation fixed this held-out case: the baseline was wrong and the augmented model matched the human label.

The selected case as numbers — all ten stored probabilities, both models
ClassNo augmentationRotation augmentation
0 · Disturbed1.18%8.92%
1 · Merging52.32%16.54%
2 · Round smooth (truth)30.55%58.49%
3 · In-between round smooth12.73%12.80%
4 · Cigar-shaped smooth0.01%0.23%
5 · Barred spiral0.12%0.22%
6 · Unbarred tight spiral0.21%0.33%
7 · Unbarred loose spiral2.82%2.31%
8 · Edge-on without bulge0.01%0.00%
9 · Edge-on with bulge0.04%0.16%

Does the result survive a paired control?

In a second, separately saved run (the paired control), the model trained with rotation started from the same weights as the baseline and saw the training images in the same order, so rotation was the only difference. In that run, rotation lowered test accuracy from 44.61% to 32.45%.

Saved experimentNo rotation accuracyRotation accuracy
Independent start (as in the notebook)44.61%55.25%
Paired start (paired control)44.61%32.45%

What the analysis shows

In the independent-start run, rotation augmentation improves every headline metric

Both models are scored on the same unrotated test galaxies, each after its final (100th) epoch.

accuracy 44.61% → 55.25% (+10.64%) · weighted F1 40.74% → 50.53% (+9.80%)

This reproduces the source notebook's favourable augmentation result.

In the same run, the calibration gap is the larger effect

Expected calibration error (ECE) measures how far a model's confidence is from its actual accuracy, regardless of how often it is right.

ECE 10.05% → 3.09% (−6.96%)

The augmented model is not merely more often right; it is much less overconfident when it is wrong.

A paired control puts rotation behind the baseline

In the independent-start run the two models differ in more than rotation: initial weights, batch order, dropout masks and rotation angles are all independent. The paired control starts both models from the same weights and the same batch order.

paired initialisation no · paired batch order no · augmented seed 0 · one run per model

With the starting point held fixed, rotation lowers test accuracy instead (44.61% → 32.45%), so the gain above is this notebook's result, not an effect of rotation alone.

Neither model separates the ten classes in the space it learned

The silhouette measures how well galaxies of the same human-assigned class group together, apart from other classes, in each 2-D map of the embedding. It is negative for every stored method, parameter setting and model.

t-SNE · perplexity = 15 · learning_rate = auto · Rotation augmentation — silhouette -0.043 · trustworthiness@10 0.995

A classifier can be right more often without pulling the human categories apart in its embedding. The table under the embedding map lists every stored value.

Where these galaxy images and labels come from

How a survey image becomes a labelled training example, and which kinds of galaxy the CNN has to tell apart.

From survey image to supervised-learning sample

  • DECaLS imaging — an optical survey records each galaxy.
  • Galaxy Zoo — volunteers answer questions about visible morphology.
  • Galaxy10 — those answers are grouped into ten broad classes.
  • This experiment — centred 64 × 64 colour images, one per galaxy.

The target is a human judgement. It is a visual-morphology category, not a spectroscopic measurement, and the ten classes are not equally frequent.

What must the CNN distinguish?

  • disturbed and merging systems;
  • three kinds of smooth galaxies;
  • barred and unbarred spirals;
  • edge-on disks with or without a bulge.

Why rotation at all. Rotating an image should not change its morphology label. That is the reason for the rotation experiment on this page.

Glossary

Every term this page uses in a specific sense, with what it means here — on this dataset, in this experiment — rather than in general.

design matrix X, and y
as used here: one row of X is one complete galaxy image flattened to its pixel-channel values; y is a separate vector holding that galaxy's human morphology class. The label is never a column of X.
rotation augmentation
as used here: an independently sampled rotation angle applied to a training image every time that row is drawn into a training mini-batch, with the label left unchanged. Validation and test images are never rotated.
epoch
one pass of the optimiser over the whole training set. Because the model trained with rotation draws a fresh angle each pass, it sees a different version of the same images in every epoch, while the baseline sees the identical images each time.
held-out test set
as used here: the portion of the split that neither model was trained or validated on. It is fixed once, before either model exists, and is identical for both models, so their two test scores can be compared directly.
confusion matrix, row-normalized
a table whose rows are true classes and whose columns are predicted classes. Row-normalized means each row is divided by its own total, so a row reads "of the galaxies that really are this class, where did the model send them?" — and class imbalance cannot make a large class look better than a small one.
weighted F1
the per-class F1 scores averaged with each class weighted by how many test galaxies it actually has. On an imbalanced set it therefore says more about the common classes than the rare ones.
reliability curve
predictions are put into confidence bins; each bin is plotted at its mean confidence against the share of it the model actually got right. The diagonal is perfect calibration; below it means overconfident.
expected calibration error (ECE)
the average distance between a bin's confidence and its accuracy, weighted by how many predictions fall in that bin. Lower is better. It says nothing about whether the model is accurate — only about whether its confidence can be believed.
logits, and softmax probabilities
the ten raw output numbers of the network, and the same ten numbers after softmax turns them into a distribution that sums to one. The probability bars in the Evaluation section are the latter.
the learned embedding
as used here: the 32 values produced by the last hidden dense layer, after its ReLU and immediately before the ten output logits. It is what the classifier actually sees, which is why the maps are drawn from it rather than from the pixels.
PCA
a linear projection onto the directions of largest variance. Its axes and its explained variance are defined quantities, but a nonlinear structure in the 32-D space can be invisible in two linear components.
t-SNE, and perplexity
a nonlinear method that places points so that local neighbourhoods survive. Perplexity is roughly how many neighbours each point is asked to keep. Cluster spacing, cluster size and the axis values are not globally meaningful.
UMAP, n_neighbors and min_dist
a nonlinear neighbourhood-graph method. n_neighbors trades local detail against broader structure; min_dist controls how tightly points may pack. As with t-SNE, the axes carry no units.
trustworthiness@10
how much of each point's ten nearest neighbours in the original 32-D space survives into the 2-D picture, on a 0–1 scale. High trustworthiness says the picture is a fair local map; it says nothing about whether the classes separate.
silhouette (against the truth labels)
as used here: how much closer a point sits to its own human class than to the nearest other class, in the 2-D view. A negative value means the classes overlap. Every value stored on this page is negative, for both models and every method.
stored case
as used here: one of 129 test galaxies whose image, true label and both models' full sets of class probabilities were saved for display. The filter counts in the Evaluation section count within these 129, not the whole test set.
fixed by rotation / broken by rotation
as used here: a stored case the baseline got wrong and the augmented model got right, and the reverse.
independent start, paired start
as used here: the two saved runs of the comparison. In the independent-start run, which is the one shown in most sections of this page, the model trained with rotation starts from its own random weights and batch order, as in the notebook. In the paired-start run (the paired control), it starts from the same weights and batch order as the baseline. The Insight page calls them Independent start and Paired start.