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

parallel version of create_tcm doesn't work #296

Closed
DavidArenburg opened this issue Feb 3, 2019 · 5 comments
Closed

parallel version of create_tcm doesn't work #296

DavidArenburg opened this issue Feb 3, 2019 · 5 comments
Labels

Comments

@DavidArenburg
Copy link

Reproducible example from the docs

library(text2vec)
data("movie_review")

# set to number of cores on your machine
N_WORKERS = 4
if(require(doParallel)) registerDoParallel(N_WORKERS)
splits = split_into(movie_review$review, N_WORKERS)
jobs = lapply(splits, itoken, tolower, word_tokenizer)
v = create_vocabulary(jobs)
# Warning message:
#   'create_vocabulary.list' is deprecated.
# Use 'create_vocabulary.itoken_parallel()' instead.
# See help("Deprecated") 

vectorizer = vocab_vectorizer(v)
jobs = lapply(splits, itoken, tolower, word_tokenizer)
tcm = create_tcm(jobs, vectorizer, skip_grams_window = 3L, skip_grams_window_context = "symmetric")
# Error in UseMethod("create_tcm") : 
#   no applicable method for 'create_tcm' applied to an object of class "list"

It looks like jobs is supposed to be something else rather a list , but I can't seem to find how to create it otherwise.

sessionInfo()
# R version 3.5.1 (2018-07-02)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows >= 8 x64 (build 9200)
# 
# Matrix products: default
# 
# locale:
# [1] LC_COLLATE=English_Israel.1252  LC_CTYPE=English_Israel.1252    LC_MONETARY=English_Israel.1252 LC_NUMERIC=C                   
# [5] LC_TIME=English_Israel.1252    
# 
# attached base packages:
# [1] parallel  stats     graphics  grDevices utils     datasets  methods   base     
# 
# other attached packages:
# [1] text2vec_0.5.1    doParallel_1.0.14 iterators_1.0.10  foreach_1.4.4    
# 
# loaded via a namespace (and not attached):
# [1] Rcpp_1.0.0           lattice_0.20-35      codetools_0.2-15     digest_0.6.18        grid_3.5.1           R6_2.3.0             futile.options_1.0.1
# [8] formatR_1.5          RcppParallel_4.4.2   data.table_1.11.8    futile.logger_1.4.3  Matrix_1.2-14        lambda.r_1.2.3       tools_3.5.1         
# [15] mlapi_0.1.0          compiler_3.5.1      
@DavidArenburg DavidArenburg changed the title parallel version of create_tcm doesn't work parallel version of create_tcm doesn't work (on Windows) Feb 3, 2019
@dselivanov
Copy link
Owner

dselivanov commented Feb 3, 2019 via email

@DavidArenburg
Copy link
Author

OK, that's fine. I had glove$fit_transform crushing RStudio, so I though I'll need to parallelise , but eventually setting n_chunks = to a higher value solved the issue.

Thanks for the package btw. You are doing a great job. Any planning to add word2vec too or you left it to the wordVectors package?

@dselivanov
Copy link
Owner

dselivanov commented Feb 3, 2019 via email

@RezaSadeghiWSU
Copy link

I faced with the similar issue in Ubuntu. Do you have any suggestion?

Regards,
Reza

@dselivanov dselivanov changed the title parallel version of create_tcm doesn't work (on Windows) parallel version of create_tcm doesn't work Mar 4, 2019
@dselivanov
Copy link
Owner

@RezaSadeghiWSU please provide reproducible example, otherwise I can't help.

Following code work on my ubuntu machine and text2vec 0.5.1:

library(text2vec, lib.loc = "~/temp/")
data("movie_review")

# set to number of cores on your machine
N_WORKERS = 4
if(require(doParallel)) registerDoParallel(N_WORKERS)
jobs = itoken_parallel(movie_review$review, tolower, word_tokenizer, n_chunks = N_WORKERS, ids = movie_review$id)
v = create_vocabulary(jobs)
vectorizer = vocab_vectorizer(v)
tcm = create_tcm(jobs, vectorizer, skip_grams_window = 3L, skip_grams_window_context = "symmetric")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants