explosion / explosion/thinc

Confusing error when passing float64 arrays to some layers

Open
#461 3 comments 0 reactions 0 assignees View on GitHub
feat / ux serialization
Dominant language
Python
Stars
2.9k
Forks
295
PR merge metrics
No merged PRs in 30d

Description

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]]))`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.