chainer / onnx-chainer

Add-on package for ONNX format support in Chainer
MIT License
85 stars 24 forks source link

model preparing ? #231

Open vlordier opened 5 years ago

vlordier commented 5 years ago

I am getting a 'Unexpected output type from the model: {}'.format(type(outputs))) and I wonder if I need to do something to prepare my Chainer model (output layer naming or something) prior to export ?

not sure how to debug that.

disktnk commented 5 years ago

The error is from https://github.com/chainer/onnx-chainer/blob/v1.5.1a1/onnx_chainer/export.py#L399

If the target model returns a value which is not chainer.Variable type, the RuntimeError would be, example:

class Model(chainer.Chain):

    def __init__(self):
        super().__init__()
        with self.init_scope():
            self.l1 = L.Linear(4)
            self.l2 = L.Linear(5, initial_bias=0.1)

    def forward(self, x):
        y = self.l1(x)
        z = self.l2(y)
        return z.array  # return numpy ndarray, not return chainer.Variable, then cannot export

If you couldn't clear the issue, could you provide reproducible source?