lonePatient / Bert-Multi-Label-Text-Classification

This repo contains a PyTorch implementation of a pretrained BERT model for multi-label text classification.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to train the model with my data?

odek53r opened this issue · comments

I adjust the config file and prepare my training data that has 15 labels in csv format, but when I train the model, I get an error as below.

ValueError: Target size (torch.Size([8, 15])) must be the same as input size (torch.Size([8, 6]))

I try to redo my data and check the generated data many times , but also get this error.

HI @odek53r, you need to modify line 55-57 in the pybert/io/bert_processor.py.

    def get_labels(self):
        """Gets the list of labels for this data set."""
        return ["toxic","severe_toxic","obscene","threat","insult","identity_hate"]

Thank you for prompt reply. It work well now!