TorchConnector¶
- class TorchConnector(neural_network, initial_weights=None, sparse=None)[source]¶
Bases:
torch.nn.Module
Connects a Qiskit (Quantum) Neural Network to PyTorch.
- Tham số:
neural_network (
NeuralNetwork
) -- The neural network to be connected to PyTorch. Remember thatinput_gradients
must be set toTrue
in the neural network initialization before passing it to theTorchConnector
for the gradient computations to work properly during training.initial_weights (
Union
[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 (
Optional
[bool
]) -- 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 it will be dense independent of the setting. Also note that PyTorch currently does not support sparse back propagation, i.e., if sparse is set to True, the backward pass of this module will return None.
Attributes
Returns the underlying neural network.
Returns whether this connector returns sparse output or not.
Returns the weights of the underlying network.
Methods
forward
([input_data])Forward pass.