Callable should be a list of existing layers in the pipeline only.
Opened this issue · 4 comments
The error handling logic in qcnn.py
(will be transferred to quantum_neural_network.py
after #36) that checks if operations[0][0]
is a Callable
should be specific in what callable functions/classes are allowed. For neural networks in general, sequence
expects operations that are inherited from the BaseLayer
class in base_layer.py
.
Without a specification of a particular quantum layer callable, in-built functions like print
, sum
, etc. pass the current tests.
I want to work on this issue to solve it. Can you please assign me this issue ?
Hi @amansingh2116, sure! Let me know if you need any help or intro to the problem.
My idea : Instead of checking if the first element of each tuple is callable
, check whether it’s a class that inherits from BaseLayer
using issubclass
function for each item in the list. Like this:
for layer, params in operations:
if not isinstance(layer, type) or not issubclass(layer, BaseLayer):
raise TypeError(f"Operation {layer} must inherit from BaseLayer.")
Please review this and check if this would solve the issue or not, so I can create a PR.
My idea : Instead of checking if the first element of each tuple is
callable
, check whether it’s a class that inherits fromBaseLayer
usingissubclass
function for each item in the list. Like this:for layer, params in operations: if not isinstance(layer, type) or not issubclass(layer, BaseLayer): raise TypeError(f"Operation {layer} must inherit from BaseLayer.")Please review this and check if this would solve the issue or not, so I can create a PR.
Could you please review and reply, so I would be assigned and can start working on the issue.