Skip to content

Added Cythonized interface for TSNE.#69

Open
sadaszewski wants to merge 1 commit intolvdmaaten:masterfrom
sadaszewski:master
Open

Added Cythonized interface for TSNE.#69
sadaszewski wants to merge 1 commit intolvdmaaten:masterfrom
sadaszewski:master

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