Skip to content

⚠️ Warning: Slow tensor creation from list of NumPy arrays in AsIsEncoder.encode #21

Closed

Description

@aditya0by0

A performance warning is triggered in the AsIsEncoder class when converting input values to PyTorch tensors.

File:
chebai_graph/preprocessing/property_encoder.py
Line: 147

Code:

def encode(self, token):
    return torch.tensor([token])

Warning message:

UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow. 
Please consider converting the list to a single numpy.ndarray with numpy.array() 
before converting to a tensor. 
(Triggered internally at torch/csrc/utils/tensor_new.cpp:257.)

While the current implementation works, it leads to performance bottlenecks when processing large batches of data, particularly when encoding RDKit2DNormalized (molecule property)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions