-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
I get a buffer error when trying to pass a scalar covariance_bound to gmm.gmm. The issue can be demonstrated with a short example:
n_samples, n_features = 100, 12
x = np.random.rand(n_samples, n_features)
cb = x.var()*0.01
m, c, prior, ll, post = cyvlfeat.gmm.gmm(x, covariance_bound=cb)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-23-570fcaba71f2> in <module>()
2 x = np.random.rand(n_samples, n_features)
3 cb = x.var()*0.0001
----> 4 m, c, prior, ll, post = gmm.gmm(x, covariance_bound=cb)
~/anaconda3/envs/core-dev/lib/python3.6/site-packages/cyvlfeat/gmm/gmm.py in gmm(X, n_clusters, max_num_iterations, covariance_bound, init_mode, init_priors, init_means, init_covars, n_repetitions, verbose)
114 n_repetitions, int(verbose),
115 covariance_bound=covariance_bound, init_priors=init_priors,
--> 116 init_means=init_means, init_covars=init_covars)
~/anaconda3/envs/core-dev/lib/python3.6/site-packages/cyvlfeat/gmm/cygmm.pyx in cyvlfeat.gmm.cygmm.cy_gmm (cyvlfeat/gmm/cygmm.c:4852)()
ValueError: Buffer has wrong number of dimensions (expected 1, got 0)
When I change the argument to a 1D array, it seems to work, at least for this toy example:
m, c, prior, ll, post = gmm.gmm(x, covariance_bound=np.array([cb]))
The difference here is between having ndim=0 and ndim=1:
>>> np.asarray(cb, dtype=np.float).ndim, np.asarray(np.array([cb]), dtype=np.float).ndim
(0, 1)
Previously, in my actual (much larger) use case, I was then getting a Buffer error that complained about getting a double instead of a float32_t, even when explicitly casting to np.float or np.float32. If I can reproduce that issue I will post a follow up.
In any case, thanks to the contributors for these wrappers, I've been finding them very useful!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels