Skip to content

Numpy issues #33

@carversh

Description

@carversh

Hi I'm running the following and getting an error. It seems to be an issue with numpy although I am using version 1.22.3:

import spams
import pandas as pd
import numpy as np

# load X input (genes by droplets/cells matrix)
X = np.load('matrix.npy')

params = {
    'K' : 15, # learns a dictionary with K modules/atoms
    'lambda1' : 0.15, 
    'lambda2':0,
    'mode':2,
    'modeD': 0,
    'numThreads' : 4, 
    'batchsize' : 400, # batchsize to learn the code
    'iter' : 15,
    'verbose':True,
    # 'gamma1': # (optional parameter for modeD >= 1),
    # 'gamma2': # (optional parameter for modeD = 2),
}

# dictionary initialization
D_init = np.random.randn(X.shape[0], params['K'])
params['D'] = D_init # dictionary initialization, if None, dictionary is initialized with random elements from the training set

#(D, model) = 
#D = spams.trainDL(np.asfortranarray(X), return_model = False, **params)
#(D,model) = spams.trainDL(X, return_model = True, lambda1=0.15, **params)
(D,model) = spams.trainDL(X, return_model = True,  **params)

And getting the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/site-packages/spams/spams.py", line 2026, in trainDL
    return __allTrainDL(X, return_model, model, False, D, None, None, numThreads, 0.000001, True, False, batchsize, K, lambda1, lambda2, lambda3, iter, t0, mode, regul, posAlpha, posD, expand, modeD, whiten, clean, verbose, gamma1, gamma2, rho, iter_updateD, stochastic_deprecated, modeParam, batch, log_deprecated, logName)
  File "/site-packages/spams/spams.py", line 1868, in __allTrainDL
    x = spams_wrap.alltrainDL(
  File "/site-packages/spams_wrap/spams_wrap.py", line 313, in alltrainDL
    return _spams_wrap.alltrainDL(*args)
RuntimeError: matrix arg 10 must be a 2d double Fortran Array

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions