API Reference

QARBoM.train!Function
train!(
    rbm::AbstractRBM,
    x_train,
    ::Type{PCD};
    n_epochs::Int,
    batch_size::Int,
    learning_rate::Vector{Float64},
    metrics::Vector{<:EvaluationMethod} = [MeanSquaredError],
    early_stopping::Bool = false,
    store_best_rbm::Bool = true,
    patience::Int = 10,
    stopping_metric::Type{<:EvaluationMethod} = MeanSquaredError,
    x_test_dataset = nothing,
    y_test_dataset = nothing,
    file_path = "pcd_metrics.csv",
)

Train an RBM using the Persistent Contrastive Divergence (PCD) algorithm.

Arguments

  • rbm::AbstractRBM: The RBM to train.
  • x_train: The training data.
  • n_epochs::Int: The number of epochs to train the RBM.
  • batch_size::Int: The size of the mini-batches.
  • learning_rate::Vector{Float64}: The learning rate for each epoch.
  • metrics::Vector{<:EvaluationMethod}: The evaluation metrics to use.
  • early_stopping::Bool: Whether to use early stopping.
  • stopping_metric::Type{<:EvaluationMethod}: The metric to use for early stopping.
  • store_best_rbm::Bool: Whether to store the rbm with the best stopping_metric.
  • patience::Int: The number of epochs to wait before stopping.
  • patience::Int: The number of epochs to wait before stopping.
  • x_test_dataset: The test data to evaluate the model. If not set the training data will be used.
  • file_path: The file path to store the metrics.
train!(
    rbm::Union{RBMClassifier, GRBMClassifier},
    x_train,
    label_train,
    ::Type{PCD};
    n_epochs::Int,
    batch_size::Int,
    learning_rate::Vector{Float64},
    label_learning_rate::Vector{Float64},
    metrics::Vector{<:EvaluationMethod} = [Accuracy],
    early_stopping::Bool = false,
    store_best_rbm::Bool = true,
    patience::Int = 10,
stopping_metric::Type{<:EvaluationMethod} = Accuracy,
    x_test_dataset = nothing,
    y_test_dataset = nothing,
    file_path = "pcd_classifier_metrics.csv",
)

Train an RBM classifier using the Persistent Contrastive Divergence (PCD) algorithm.

Arguments

  • rbm::RBMClassifier: The RBM classifier to train.
  • x_train: The training data.
  • label_train: The training labels.
  • n_epochs::Int: The number of epochs to train the RBM.
  • batch_size::Int: The size of the mini-batches.
  • learning_rate::Vector{Float64}: The learning rate for each epoch.
  • label_learning_rate::Vector{Float64}: The learning rate for the labels for each epoch.
  • metrics::Vector{<:EvaluationMethod}: The evaluation metrics to use.
  • early_stopping::Bool: Whether to use early stopping.
  • stopping_metric::Type{<:EvaluationMethod}: The metric to use for early stopping.
  • store_best_rbm::Bool: Whether to store the rbm with the best stopping_metric.
  • patience::Int: The number of epochs to wait before stopping.
  • patience::Int: The number of epochs to wait before stopping.
  • x_test_dataset: The test data to evaluate the model. If not set the training data will be used.
  • y_test_dataset: The test labels to evaluate the model. If not set the training labels will be used.
  • file_path: The file path to store the metrics.
train!(
    rbm::AbstractRBM,
    x_train,
    ::Type{FastPCD};
    n_epochs::Int,
    gibbs_steps::Int = 1,
    batch_size::Int,
    learning_rate::Vector{Float64},
    fast_learning_rate::Float64,
    metrics::Vector{<:DataType} = [MeanSquaredError],
    early_stopping::Bool = false,
    store_best_rbm::Bool = true,
    patience::Int = 10,
    stopping_metric::Type{<:EvaluationMethod} = MeanSquaredError,
    x_test_dataset = nothing,
    file_path = "fast_pcd_metrics.csv",
)

Train an RBM using Fast Persistent Contrastive Divergence (FastPCD) algorithm.

Tieleman and Hinton (2009) "Using fast weights to improve persistent contrastive divergence"

Arguments

  • rbm::AbstractRBM: The RBM to train.
  • x_train: The training data.
  • n_epochs::Int: The number of epochs to train the RBM.
  • gibbs_steps::Int: The number of Gibbs Sampling steps to use.
  • batch_size::Int: The size of the mini-batches.
  • learning_rate::Vector{Float64}: The learning rate for each epoch.
  • fast_learning_rate::Float64: The fast learning rate.
  • metrics::Vector{<:EvaluationMethod}: The evaluation metrics to use.
  • early_stopping::Bool: Whether to use early stopping.
  • stopping_metric::Type{<:EvaluationMethod}: The metric to use for early stopping.
  • store_best_rbm::Bool: Whether to store the rbm with the best stopping_metric.
  • patience::Int: The number of epochs to wait before stopping.
  • x_test_dataset: The test data.
  • file_path: The file path to save the metrics.
train!(
    rbm::Union{RBMClassifier, GRBMClassifier},
    x_train,
    label_train,
    ::Type{FastPCD};
    n_epochs::Int,
    gibbs_steps::Int = 1,
    batch_size::Int,
    learning_rate::Vector{Float64},
    fast_learning_rate::Float64,
    label_learning_rate::Vector{Float64},
    metrics::Vector{<:DataType} = [Accuracy],
    early_stopping::Bool = false,
    store_best_rbm::Bool = true,
    patience::Int = 10,
    stopping_metric::Type{<:EvaluationMethod} = Accuracy,
    x_test_dataset = nothing,
    y_test_dataset = nothing,
    file_path = "fast_pcd_classifier_metrics.csv",
)

Train an RBM using Fast Persistent Contrastive Divergence (FastPCD) algorithm.

Tieleman and Hinton (2009) "Using fast weights to improve persistent contrastive divergence"

Arguments

  • rbm::RBMClassifier: The RBM to train.
  • x_train: The training data.
  • label_train: The training labels.
  • n_epochs::Int: The number of epochs to train the RBM.
  • gibbs_steps::Int: The number of Gibbs Sampling steps to use.
  • batch_size::Int: The size of the mini-batches.
  • learning_rate::Vector{Float64}: The learning rate for each epoch.
  • fast_learning_rate::Float64: The fast learning rate.
  • label_learning_rate::Vector{Float64}: The label learning rate for each epoch.
  • fast_label_learning_rate::Float64: The fast label learning rate.
  • metrics::Vector{<:EvaluationMethod}: The evaluation metrics to use.
  • early_stopping::Bool: Whether to use early stopping.
  • stopping_metric::Type{<:EvaluationMethod}: The metric to use for early stopping.
  • store_best_rbm::Bool: Whether to store the rbm with the best stopping_metric.
  • patience::Int: The number of epochs to wait before stopping.
  • x_test_dataset: The test data.
  • y_test_dataset: The test labels.
  • file_path: The file path to save the metrics.
train!(
    rbm::RBMClassifiers,
    x_train,
    label_train,
    ::Type{QSampling};
    n_epochs::Int,
    gibbs_steps::Int,
    batch_size::Int,
    learning_rate::Vector{Float64},
    label_learning_rate::Vector{Float64},
    metrics::Vector{<:DataType} = [Accuracy],
    early_stopping::Bool = false,
    store_best_rbm::Bool = true,
    patience::Int = 10,
    stopping_metric::Type{<:EvaluationMethod} = Accuracy,
    x_test_dataset = nothing,
    y_test_dataset = nothing,
    file_path = "qsamp_classifier_metrics.csv",
    model_setup::Function,
    sampler,
    kwargs...,
)

Train an RBMClassifier using Quantum sampling.

Arguments

  • rbm::RBMClassifier: The RBM classifier to train.

  • x_train: The training data.

  • label_train: The training labels.

  • n_epochs::Int: The number of epochs to train the RBM.

  • gibbs_steps::Int: The number of Gibbs steps to use.

  • batch_size::Int: The size of the mini-batches.

  • learning_rate::Vector{Float64}: The learning rate for each epoch.

  • label_learning_rate::Vector{Float64}: The learning rate for the labels for each epoch.

  • metrics::Vector{<:EvaluationMethod}: The evaluation metrics to use.

  • early_stopping::Bool: Whether to use early stopping.

  • stopping_metric::Type{<:EvaluationMethod}: The metric to use for early stopping.

  • store_best_rbm::Bool: Whether to store the rbm with the best stopping_metric.

  • patience::Int: The number of epochs to wait before stopping.

  • x_test_dataset: The test data to evaluate the model. If not set the training data will be used.

  • y_test_dataset: The test labels to evaluate the model. If not set the training labels will be used.

  • file_path: The file path to store the metrics.

  • handle_error::Function: The function to handle errors during training.

  • model_setup::Function: The function to setup the QUBO sampler.

  • sampler: The QUBO sampler to use.

  • kwargs...: Additional arguments for the QUBO sampler

    • max_visible::Vector{Float64}: The maximum value for the visible nodes.
    • min_visible::Vector{Float64}: The minimum value for the visible nodes.
    • num_evaluated_states::Int: The top N quantum-sampled states to be considered for update.
    • variable_encoding_tolerance::Float64: Custom tolerance for the variable encoding