TorchRuntimeClient¶
- class TorchRuntimeClient(model, optimizer, loss_func, epochs=10, shots=1024, measurement_error_mitigation=False, provider=None, backend=None)[kaynak]¶
Bases:
object
Deprecation: TorchRuntimeClient
The Qiskit Machine Learning Torch runtime client to call the Torch runtime.
- Parametreler:
model (torch.nn.Module) – A PyTorch module to be trained.
optimizer (torch.optim.Optimizer) – A PyTorch optimizer for the model parameters.
loss_func (Callable) – A PyTorch-compatible loss function. Can be one of the official PyTorch loss functions from
torch.nn.loss
or a custom function defined by the user.epochs (int) – The maximum number of training epochs. By default, 10.
shots (int) – The number of shots for the quantum backend. By default, 1024.
measurement_error_mitigation (bool) – Whether or not to use measurement error mitigation.
default (By) –
False. –
provider (Provider | None) – IBMQ provider that supports runtime services.
backend (Backend | None) – Selected quantum backend.
Attributes
Return the loss function.
Returns whether or not to use measurement error mitigation.
Return the model.
Return the optimizer.
Return the provider.
Return the number of shots.
Methods
fit
(train_loader[, val_loader, hooks, ...])Train the model using the Torch Train Runtime ('torch-train').
predict
(data_loader)Perform prediction on the passed data using the trained model and the Torch Infer Runtime ('torch-infer').
score
(data_loader, score_func)Calculate a score using the trained model and the Torch Infer Runtime ('torch-infer').