ggml_opt_dataset_weights: Get dataset loss weights tensor

View source: R/optimizer.R

ggml_opt_dataset_weightsR Documentation

Get dataset loss weights tensor

Description

Returns the (lazily allocated) loss weights tensor with shape [ne0, ndata]. The first call allocates it; fill it via ggml_backend_tensor_set_data(). Used together with ggml_opt_loss_type_weighted_mse.

Usage

ggml_opt_dataset_weights(dataset, ne0 = 1L)

Arguments

dataset

External pointer to dataset

ne0

Width of the weight tensor: 1 for per-datapoint weights, or the label width for a per-output mask.

Details

ne0 = 1 gives one weight per datapoint, broadcast over the outputs – the original behaviour. ne0 = ne_label gives a per-output-element mask, which is what a Q-model needs: weight 1 on the action that has a TD target, 0 elsewhere, so only that coordinate is trained.

The mask does not change the denominator: the loss stays sum(w * (pred - y)^2) / nelements(pred), so zeroed elements drop out of the numerator without renormalising over the active coordinates.

Calling this again with a different ne0 than the allocation is an error rather than a silent return of the cached tensor – both shapes broadcast, so a mismatch would otherwise weight the wrong thing unnoticed.

Value

External pointer to weights tensor

See Also

Other optimization: ggml_fit_opt(), ggml_fit_opt_gen(), ggml_fit_opt_multi(), ggml_opt_alloc(), ggml_opt_context_optimizer_type(), ggml_opt_dataset_data(), ggml_opt_dataset_free(), ggml_opt_dataset_get_batch(), ggml_opt_dataset_get_batch_head(), ggml_opt_dataset_init(), ggml_opt_dataset_labels(), ggml_opt_dataset_ndata(), ggml_opt_dataset_shuffle(), ggml_opt_default_params(), ggml_opt_epoch(), ggml_opt_eval(), ggml_opt_fit(), ggml_opt_fit_multi(), ggml_opt_free(), ggml_opt_get_lr(), ggml_opt_grad_acc(), ggml_opt_init(), ggml_opt_init_for_fit(), ggml_opt_init_for_fit_multi(), ggml_opt_inputs(), ggml_opt_labels(), ggml_opt_loss(), ggml_opt_loss_i(), ggml_opt_loss_type_binary_cross_entropy(), ggml_opt_loss_type_cross_entropy(), ggml_opt_loss_type_huber(), ggml_opt_loss_type_mae(), ggml_opt_loss_type_mean(), ggml_opt_loss_type_mse(), ggml_opt_loss_type_sum(), ggml_opt_loss_type_weighted_mse(), ggml_opt_n_loss(), ggml_opt_ncorrect(), ggml_opt_optimizer_name(), ggml_opt_optimizer_type_adamw(), ggml_opt_optimizer_type_sgd(), ggml_opt_outputs(), ggml_opt_outputs_i(), ggml_opt_pred(), ggml_opt_prepare_alloc(), ggml_opt_reset(), ggml_opt_result_accuracy(), ggml_opt_result_free(), ggml_opt_result_init(), ggml_opt_result_loss(), ggml_opt_result_loss_i(), ggml_opt_result_n_loss(), ggml_opt_result_ndata(), ggml_opt_result_pred(), ggml_opt_result_reset(), ggml_opt_set_lr(), ggml_opt_static_graphs(), ggml_snapshot_free(), ggml_trainer()


ggmlR documentation built on Oct. 23, 2026, 1:07 a.m.