Skip to content

Confusing error when passing float64 arrays to some layers #461

@lbenc135

Description

@lbenc135

I'm try to load a model from disk which I saved previously, and run predict on it, but it produces the following error:

...
    predicted = self.model.predict(X)[0]
../../venv/lib/python3.8/site-packages/thinc/model.py:312: in predict
    return self._func(self, X, is_train=False)[0]
../../venv/lib/python3.8/site-packages/thinc/layers/chain.py:54: in forward
    Y, inc_layer_grad = layer(X, is_train=is_train)
../../venv/lib/python3.8/site-packages/thinc/model.py:288: in __call__
    return self._func(self, X, is_train=is_train)
../../venv/lib/python3.8/site-packages/thinc/layers/relu.py:44: in forward
    Y = model.ops.affine(X, W, b)
../../venv/lib/python3.8/site-packages/thinc/backends/ops.py:203: in affine
    Y = self.gemm(X, W, trans2=True)
thinc/backends/numpy_ops.pyx:84: in thinc.backends.numpy_ops.NumpyOps.gemm
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   ValueError: Buffer dtype mismatch, expected 'const double' but got 'float'

blis/py.pyx:64: ValueError

I don't get the error when I do train -> predict. Only when doing train -> to_disk -> from_disk -> predict. I've tried with bytes instead of disk, but the same error appears.

Model:

model = chain(
    Relu(10),
    Relu(1),
    Logistic()
)
model.from_disk('model.bin')

Input: model.ops.asarray(np.array([[0., 0., 0.5]]))

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat / uxUser experience, error messages etc.serializationSaving and loading models

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions