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

Added Cythonized interface for TSNE. #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sadaszewski
Copy link

No description provided.

@lvdmaaten
Copy link
Owner

lvdmaaten commented Mar 19, 2018

Thanks, the current approach of writing data to a file and running an executable that reads those files is, indeed, super-clunky.

I'm wondering if/why we need the Cython dependency though? Wouldn't this be much easier solved by calling tsne_run via FFI? Something along these lines ought to work:

import ctypes
tsne_lib = ctypes.cdll.LoadLibrary('libtsne.so')
c_data = data.ctypes.data_as(ctypes.POINTER(ctypes.c_double))	
c_mappedX = mappedX.ctypes.data_as(ctypes.POINTER(ctypes.c_double))	
tsne_lib.tsne_run(	
        c_data,	
        ctypes.c_int(N),	
        ctypes.c_int(D),	
        c_mappedX,	
        ctypes.c_int(numDims),	
        ctypes.c_double(perplexity),	
        ctypes.c_double(theta),	
        ctypes.c_int(randomSeed),
        ctypes.c_int(skipRandomInit),	
        ctypes.c_int(maxIter),	
        ctypes.c_int(stopLyingIter),	
        ctypes.c_int(momSwitchIter),
)

This wouldn't require any additional dependencies. What do you think?

@sadaszewski
Copy link
Author

sadaszewski commented Mar 19, 2018 via email

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

Successfully merging this pull request may close these issues.

2 participants