TorchConnectorで量子層をPyTorchに統合
self.quantum_layer = TorchConnector(self.qnn)
# 古典的後処理層
self.classical_post = nn.Sequential(
nn.Linear(1, 16),
nn.ReLU(),
nn.Linear(16, n_classes),
nn.Softmax(dim=1)
)
def forward(self, x: torch.Tensor) -> torch.Tensor:
x = self.classical_pre(x)
x = self.quantum_layer(x)
x = self.classical_post(x)
return x
print("ハイブリッド量子古典モデルの定義完了")