TorchConnector#

class TorchConnector(*args, **kwargs)[स्रोत]#

आधार: torch.nn.Module

Connects a Qiskit (Quantum) Neural Network to PyTorch.

मापदण्ड:
  • neural_network (NeuralNetwork) -- The neural network to be connected to PyTorch. Remember that input_gradients must be set to True in the neural network initialization before passing it to the TorchConnector for the gradient computations to work properly during training.

  • initial_weights (np.ndarray | Tensor | None) -- The initial weights to start training the network. If this is None, the initial weights are chosen uniformly at random from [-1, 1].

  • sparse (bool | None) -- Whether this connector should return sparse output or not. If sparse is set to None, then the setting from the given neural network is used. Note that sparse output is only returned if the underlying neural network also returns sparse output, otherwise an error will be raised.

उभारता है :

QiskitMachineLearningError -- If the connector is configured as sparse and the underlying network is not sparse.

Attributes

neural_network#

Returns the underlying neural network.

sparse#

Returns whether this connector returns sparse output or not.

weight#

Returns the weights of the underlying network.

Methods

forward(input_data=None)[स्रोत]#

Forward pass.

मापदण्ड:

input_data (Tensor | None) -- data to be evaluated.

प्रदत्त :

Result of forward pass of this model.

प्रदत्त प्रकार :

Tensor