QRNN
- class typhon.retrieval.qrnn.qrnn.QRNN(input_dimensions, quantiles=None, model=(3, 128, 'relu'), ensemble_size=1, **kwargs)[source]
Quantile Regression Neural Network (QRNN)
This class provides a high-level implementation of quantile regression neural networks. It can be used to estimate quantiles of the posterior distribution of remote sensing retrievals.
The
QRNN`
class uses an arbitrary neural network model, that is trained to minimize the quantile loss function\[\begin{split}\mathcal{L}_\tau(y_\tau, y_{true}) = \begin{cases} (1 - \tau)|y_\tau - y_{true}| & \text{ if } y_\tau < y_\text{true} \\ \tau |y_\tau - y_\text{true}| & \text{ otherwise, }\end{cases}\end{split}\]where \(x_\text{true}\) is the true value of the retrieval quantity and and \(x_\tau\) is the predicted quantile. The neural network has one output neuron for each quantile to estimate.
The QRNN class provides a generic QRNN implementation in the sense that it does not assume a fixed neural network architecture or implementation. Instead, this functionality is off-loaded to a model object, which can be an arbitrary regression network such as a fully-connected or a convolutional network. A range of different models are provided in the typhon.retrieval.qrnn.models module. The
QRNN`
class just implements high-level operation on the QRNN output while training and prediction are delegated to the model object. For details on the respective implementation refer to the documentation of the corresponding model class.Note
For the QRNN implementation \(x\) is used to denote the input vector and \(y\) to denote the output. While this is opposed to inverse problem notation typically used for retrievals, it is in line with machine learning notation and felt more natural for the implementation. If this annoys you, I am sorry.
- backend
The name of the backend used for the neural network model.
- Type:
str
- quantiles
The 1D-array containing the quantiles \(\tau \in [0, 1]\) that the network learns to predict.
- Type:
numpy.array
- model
The neural network regression model used to predict the quantiles.
- __init__(input_dimensions, quantiles=None, model=(3, 128, 'relu'), ensemble_size=1, **kwargs)[source]
Create a QRNN model.
- Parameters:
input_dimensions (int) – The dimension of the measurement space, i.e. the number of elements in a single measurement vector y
quantiles (np.array) – 1D-array containing the quantiles to estimate of the posterior distribution. Given as fractions within the range [0, 1].
model – A (possibly trained) model instance or a tuple
(d, w, act)
describing the architecture of a fully-connected neural network withd
hidden layers withw
neurons andact
activation functions.
Methods
__init__
(input_dimensions[, quantiles, ...])Create a QRNN model.
calibration
(*args, **kwargs)Compute calibration curve for the given dataset.
cdf
(x)Approximate the posterior CDF for given inputs x.
classify
(x, threshold)Classify output based on posterior PDF and given numeric threshold.
crps
(y_pred, y_test, quantiles)Compute the Continuous Ranked Probability Score (CRPS) for given quantile predictions.
evaluate_crps
(x_test, y_test)Predict quantiles and compute the Continuous Ranked Probability Score (CRPS).
load
(path)Load a model from a file.
pdf
(x)Approximate the posterior probability density function (PDF) for given inputs
x
.Computes the posterior mean by computing the first moment of the estimated posterior CDF.
predict
(x)Predict quantiles of the conditional distribution P(y|x).
sample_posterior
(x[, n])Generates
n
samples from the estimated posterior distribution for the input vectorx
.sample_posterior_gaussian_fit
(x[, n])Generates
n
samples from the estimated posterior distribution for the input vectorx
.save
(path)Store the QRNN model in a file.
train
(training_data[, validation_data, ...])Train model on given training data.