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

Use of os.fork breaks Windows support #42

Open
jlorince opened this issue Oct 4, 2016 · 3 comments
Open

Use of os.fork breaks Windows support #42

jlorince opened this issue Oct 4, 2016 · 3 comments

Comments

@jlorince
Copy link

jlorince commented Oct 4, 2016

Changes in 5d347d1 breaks Windows support, as Windows doesn't support os.fork. Wish I could propose a fix, but I'm not sure if/how to achieve the same sort of functionality in Windows. As a stopgap, I suppose the use of the forked process could just be conditional on platform...

@lvdmaaten
Copy link
Owner

Yeah that doesn't sound like a bad solution for now. I don't have access to a Windows-machine, so would you mind taking a crack at it @jlorince?

@nitheshj
Copy link

@jlorince It would be helpful if you can elaborate on the stopgap solution. I'm trying to run this in windows and os.fork is causing the issues. Thanks in advance.

@AliFlux
Copy link

AliFlux commented Jun 6, 2019

I ended up modifying the code to remove the fork. Turns out, fork is just used to make the command prompt responsive to keyboard interrupts. Removing that also makes this compatible with jupyter and spyder.

Just replace the function with this one:

def run_bh_tsne(data, no_dims=2, perplexity=50, theta=0.5, randseed=-1, verbose=False, initial_dims=50, use_pca=True, max_iter=1000):
    '''
    Run TSNE based on the Barnes-HT algorithm

    Parameters:
    ----------
    data: file or numpy.array
        The data used to run TSNE, one sample per row
    no_dims: int
    perplexity: int
    randseed: int
    theta: float
    initial_dims: int
    verbose: boolean
    use_pca: boolean
    max_iter: int
    '''

    tmp_dir_path = mkdtemp()

    if _is_filelike_object(data):
        data = load_data(data)

    init_bh_tsne(data, tmp_dir_path, no_dims=no_dims, perplexity=perplexity, theta=theta, randseed=randseed,verbose=verbose, initial_dims=initial_dims, use_pca=use_pca, max_iter=max_iter)

    res = []
    for result in bh_tsne(tmp_dir_path, verbose):
        sample_res = []
        for r in result:
            sample_res.append(r)
        res.append(sample_res)
    rmtree(tmp_dir_path)
    return np.asarray(res, dtype='float64')

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

4 participants