Closed jimzhou112 closed 3 years ago
Hi,
The way pytorch integration works is that we first export the pytorch model to onnx format and then use the onnx2keras library to transform the onnx model to keras. At each step we check whether the transformation was successful by running the new model on some dummy input and compare the output against that of the previous version. Your log tells me that the first step worked but the second (onnx to keras) didn't. Because this transformation is handled by the onnx2keras tool, you'd have to check their documentation to see if your network architecture might contain something that isn't supported by them.
Hello,
Thank you for the insights. However, I don't see any discrepancies between my model architecture and their supported architecture. My model is a simple one layer CNN composed of a conv, relu, and fc. Below is the model in PyTorch
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
# The input_shape field is required by SNN toolbox.
self.input_shape = (1, 7, 7)
self.conv = nn.Conv2d(1, 6, kernel_size=3, stride=1)
self.relu = nn.ReLU()
self.fc1 = nn.Linear(150, 23)
def forward(self, x):
x = self.relu(self.conv(x))
x = x.view(x.size(0), -1)
x = self.fc1(x)
return x
I've also attached my python script (based off this example). Do you have any other insights as to how I can resolve the error? Thanks for all the help.
Didn't see anything obviously off in the code.
Since the model is so simple, a way to debug / circumvent this could be to instantiate the model in keras instead and transfer the weights manually; then see if the conversion goes through.
Sorry that I can't really help debug the assertion error itself right now.
I'm using snn_toolbox to convert a PyTorch model into SNN for simulation or deployment. When I invoke the toolbox within my python script (snntoolbox.bin.run.main(path_to_config_file)), I get the following error and stack trace:
My config file:
Thanks in advance for any help