Skip to content

Textattack for cuml models not utilising much GPU resources #790

@farwashah6

Description

@farwashah6

Hi. I am new to using GPU. I have used the Textattack library earlier for one of my projects using Sklearn and Keras models. For that I created the customModelWrappers according to my models and they worked fine. Now since my data is different and very big, I want to implement it using GPU for the same (sklearn) models.

I have the understanding that sklearn models do not implement on GPU and I have to use CUML instead. But when I use CUML, and pass the cuml model to the CustomModelWrapper I created earlier, it gives me the following error
len() of unsized object
and then stops the execution.

Additional Info: For vectorisation of my data I am using CountVectorizer of cuml, which is the cause of this error. Instead when I use CountVectorizer of sklearn it does the attack but doesn't use much GPU resources (of course). Please help me in this.

I am attaching my modelWrapper here.

class CustomModelWrapper(ta.models.wrappers.ModelWrapper):

    def __init__(self, model, vectorizer):
        super().__init__()
        self.model = model
        self.vectorizer = vectorizer

    def __call__(self, text_input_list, batch=None):
        x_transform = self.vectorizer.transform(pd.Series(text_input_list)).astype(float)
        prediction = self.model.predict_proba(x_transform)
        return prediction

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions