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

RCPP Not Compatible #127

Open
lkoll opened this issue Jul 19, 2018 · 12 comments
Open

RCPP Not Compatible #127

lkoll opened this issue Jul 19, 2018 · 12 comments

Comments

@lkoll
Copy link

lkoll commented Jul 19, 2018

I am attempting to use the R implementation of Rsomoclu.train with the following parameters on a sparse matrix, dimensions 480k x 18k.

nEpochs<-5
nx<-70
ny<-70
som_train<-Rsomoclu.train(dfm,
                          nEpoch=nEpochs,
                          nSomX = nx,
                          nSomY = ny,
                          kernelType = 2,
                          radius0 = 0,
                          radiusN = 1,
                          radiusCooling = "linear",
                          scale0 = 1,
                          scaleN = .01,
                          scaleCooling = "linear")

When I run this it fails almost instantly with the following error:

> som_train<-Rsomoclu.train(dfm,
+                           nEpoch=nEpochs,
+                           nSomX = nx,
+                           nSomY .... [TRUNCATED] 
terminate called after throwing an instance of 'Rcpp::not_compatible'
  what():  Not compatible with requested type: [type=S4; target=double].

Am I setting a parameter incorrectly?

@xgdgsc
Copy link
Collaborator

xgdgsc commented Jul 19, 2018

Can you provide a MWE with the dfm?

@lkoll
Copy link
Author

lkoll commented Jul 19, 2018 via email

@xgdgsc
Copy link
Collaborator

xgdgsc commented Jul 19, 2018

@lkoll
Copy link
Author

lkoll commented Jul 19, 2018

MWE.txt
Here is the first 1000 rows of my dfm, I ran it with the same parameters I was using on the whole thing and it immediately errored out again. Not sure if you need the below or not but it's the structure of the matrix MWE.

Formal class 'dgTMatrix' [package "Matrix"] with 6 slots
  ..@ i       : int [1:220352] 378 303 532 652 699 920 923 966 977 239 ...
  ..@ j       : int [1:220352] 0 6 6 6 6 6 6 6 6 7 ...
  ..@ Dim     : int [1:2] 1000 17770
  ..@ Dimnames:List of 2
  .. ..$ : NULL
  .. ..$ : NULL
  ..@ x       : num [1:220352] 4 5 1 2 3 2 5 5 2 2 ...
  ..@ factors : list()

@lkoll
Copy link
Author

lkoll commented Jul 21, 2018

@xgdgsc
Just wanted to make sure you received my dataset, please let me know if you find anything out.

@xgdgsc
Copy link
Collaborator

xgdgsc commented Jul 24, 2018

library('Rsomoclu')
data("rgbs", package = "Rsomoclu")
dfm = read.csv("~/tmp/MWE.txt",sep = " ")
dfm_m = data.matrix(dfm)
nEpochs<-5
nx<-70
ny<-70
som_train<-Rsomoclu.train(dfm_m,
                          nEpoch=nEpochs,
                          nSomX = nx,
                          nSomY = ny,
                          kernelType = 0,
                          radius0 = 0,
                          radiusN = 1,
                          radiusCooling = "linear",
                          scale0 = 1,
                          scaleN = .01,
                          scaleCooling = "linear")

it' s a problem with not converting your dataframe.

and you have to remove the header:

screenshot_20180724_220356

@lkoll
Copy link
Author

lkoll commented Jul 24, 2018

I don't think that's my issue. When you read in the data use the "Matrix" package readMM function as follows. It is already in sparse matrix form when I run it.

dfm<-readMM("MWE.txt")
> str(dfm)
Formal class 'dgTMatrix' [package "Matrix"] with 6 slots
  ..@ i       : int [1:220352] 378 303 532 652 699 920 923 966 977 239 ...
  ..@ j       : int [1:220352] 0 6 6 6 6 6 6 6 6 7 ...
  ..@ Dim     : int [1:2] 1000 17770
  ..@ Dimnames:List of 2
  .. ..$ : NULL
  .. ..$ : NULL
  ..@ x       : num [1:220352] 4 5 1 2 3 2 5 5 2 2 ...
  ..@ factors : list()

@xgdgsc
Copy link
Collaborator

xgdgsc commented Jul 24, 2018

Since matrix is the only type we support here. You may need to convert like:

dfm<-readMM("~/tmp/MWE.txt")
dfm_m = as.matrix(dfm)
...

It seems to take much more memory. So the recommended way of using in this case is the cmd line version.

@lkoll
Copy link
Author

lkoll commented Jul 24, 2018

I was under the impression that sparse matrices were supported because of the kernel type option of "Sparse CPU" in the following documentation (https://cran.r-project.org/web/packages/Rsomoclu/Rsomoclu.pdf). So there is no sparse matrix support for this package?

Edit:
The following sources also seem to indicate that there is...
https://peterwittek.com/training-emergent-self-organizing-maps-with-somoclu.html
https://arxiv.org/abs/1305.1422

@xgdgsc
Copy link
Collaborator

xgdgsc commented Jul 24, 2018

The support is mainly in the cli version. We didn' t use R intensively to think about this issue.

@lkoll
Copy link
Author

lkoll commented Jul 24, 2018

It may be a good idea to update your R documentation in that case.

What is cli?

@xgdgsc
Copy link
Collaborator

xgdgsc commented Jul 25, 2018

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

No branches or pull requests

2 participants