Skip to content

Can the sampled function f be treated as a black box? #31

@Buantum

Description

@Buantum

I'd like to further confirm my understanding of how xfac interacts with the user-provided function f.

My main question is: can f be treated as a complete black box? Specifically, is it sufficient for f to have a signature that accepts the required input (e.g., an index/coordinate structure) and returns a standard scalar type (like double, int, float) to be used by xfac for TCI sampling?

Following up on this, is the primary purpose of the wrapper around f within the TensorCI2 class simply to add an optional caching layer?

To make my "black box" question clearer, consider a function with a side effect, like the following Python-style pseudo-code:
def f(x): print(x) return 2 * x
If a function like this is passed to the TCI algorithm, will the print(x) statement be executed every time the function is sampled?

Extending this idea further, can I also set f to be a neural network defined in PyTorch (and loaded in C++ via LibTorch)? My assumption is that this is also possible, as long as my wrapper function converts the final torch::Tensor output back into a scalar value before returning.

Thank you for your clarification.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions