Skip to content

tsne.fit_transform() prematurely ends before function return in a function call #124

@ruyian

Description

@ruyian

I encountered an issue while working on my project and reported it on GitHub. The issue relates to a specific function call within my code.

I have a code snippet that includes a function call to fit_transform() as shown below:

def f():
    ...

    logger.info("Start TSNE")
    reduced_features = TSNE(n_components=2, perplexity=15, learning_rate=10).fit_transform(features)
    logger.info("Finish TSNE for features")

    ...
    return reduced_features

def main():
    ...
    f()
    logger.info("Finished dim reduction")

    g()

In this code excerpt, I've incorporated a call to fit_transform(). Utilizing a logger, I aim to document the execution progress. However, I observed that only the message "Start TSNE" is logged, while the subsequent log messages are conspicuously absent. Adding to the complexity, the function g() is unexpectedly invoked even though the preceding function f() should return a value that serves as an argument for g().

What's even more puzzling is that the program ends with g() triggering an exception, indicating that it is executed before the completion of f(). This behavior is not only unexpected and peculiar, given the dependency of g() on the return value of f().

I suspect that there might be an element of parallelization at play here. However, the complicating factor is that g() requires an argument that hinges on the output of f()'s t-SNE transformation.

I'm reaching out for insights into why this behavior is occurring and, more importantly, how to effectively address it. Your assistance in unraveling this conundrum would be immensely appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions