Computational requirements for implementing autoencoder grid searches and spectral reconstruction loss in unsupervised latent space clustering of osteosarcoma X-ray spectra have been detailed in recent Nature documentation.
To select the best autoencoder models, researchers performed an exhaustive grid search for both the 2-channel signal data and the preprocessed data.
All tested autoencoders follow a specific architecture where the encoder consists of a sequence of 1D convolutions, followed by flattening and a single-layer MLP mapping signals to a 2-dimensional latent space.
A final 1D convolution with kernel size 1, preceded by a symmetric sequence of 1D deconvolutions and a single-layer MLP, makes up the decoder layout, which brings the channel count down to align with the dimensionality of the input. Output padding allowed models to produce sequences matching input lengths, while all signals were padded with their mean using symmetric padding of length 20.
Hyperparameters explored in the grid search included `n_layers` (number of convolutional layers in the encoder, equal to the number of deconvolutions in the decoder), `h_dims` (number of channels of all but the last [de]encoder’s [de]convolutions), `final_conv_dim` (number of channels of the final encoder’s convolution, equal to the input channel dimension), `kernel_size` (kernel size of the [de]convolutions of the model, except the final one), and `stride` (stride of all the [de]convolutions except the last one).
For the autoencoder reconstructing 2-channel signals, researchers selected hyperparameters yielding the lowest L1 loss on the validation set, resulting in a model with `n_layers=4`, `h_dims=128`, `final_conv_dim=8`, `kernel_size=8`, and `stride=2`. For the autoencoder reconstructing preprocessed signals, the team selected the model achieving the lowest L1 loss on the validation set among candidates with `n_layers=1` and `final_conv_dim<8` to reduce parameters and overall model complexity.
The best model among these candidates featured `final_conv_dim=4`, `kernel_size=8`, and `stride=1`. For the clustering stage, a grid search explored clustering algorithms and their respective hyperparameters, with model selection based on the silhouette score to measure cluster quality consistently. Clustering algorithms were applied to the joint train and validation set using two-dimensional representations obtained from PCA or selected autoencoders.
Computational requirements were evaluated on a single NVIDIA GeForce RTX 5090 GPU. The preprocessed-signal autoencoder required approximately 0.051 seconds per training epoch with a peak allocated GPU memory of 0.028 GB. Under the final training configuration, the two-channel autoencoder took roughly 0.076 seconds per training epoch alongside a peak PyTorch tensor memory allocation of 0.113 GB, denoting the wall-clock duration per epoch and maximum GPU memory used.
For final models, reconstruction loss combined a standard L1 term with additional peak- and gradient-sensitive contributions, defined as $\mathcal {L}_{\textrm{rec}} = \mathcal {L}_{\textrm{L1}} + 2\,\mathcal {L}_{\textrm{peak}} + \mathcal {L}_{\textrm{grad}}$.
The formulation comprised \mathcal {L}\textrm{L1} = \operatorname {MAE}(\hat{y},y) alongside $\mathcal {L}_{\textrm{peak}} = \operatorname {MAE}(M\odot \hat{y},M\odot y)$ and $\mathcal {L}_{\textrm{grad}} = \operatorname {MAE}(\Delta \hat{y},\Delta y)$, where target and reconstructed spectra are represented respectively by $y$ and \hat{y}, element-wise multiplication is indicated by \odot, and the first finite-difference operator is given by \Delta.