Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain hook does not support ndarray #216

Closed
disktnk opened this issue Aug 4, 2019 · 0 comments · Fixed by #221
Closed

Retain hook does not support ndarray #216

disktnk opened this issue Aug 4, 2019 · 0 comments · Fixed by #221

Comments

@disktnk
Copy link
Member

disktnk commented Aug 4, 2019

Process of exporting retains references of input value to output temporary values using RetainInputHook. This hook only supports chainer.Variable, so if the target model handles chainer.Chain accepting numpy.ndarray, cause ValueError.

class Model(chainer.Chain):

    def forward(self, x, h):
        return x + h

class ParentModel(chainer.Chain):

    def __init__(self):
        super().__init__()
        self.h = np.array(5, dtype=np.float32)
        with self.init_scope():
            self.m = Model()

    def forward(self, x):
        return self.m(x, self.h)

x  = chainer.Variable(np.array(3, dtype=np.float32))
export(ParentModel(), (x,))
E           ValueError: type <class 'numpy.ndarray'> is not supported to retain input

ref #201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant