Skip to content

"Encounter of RuntimeError at the Second Epoch in BERT Multiclass Text Classification" #1

@abhay-create

Description

@abhay-create

@Vidhi1290 I just want to thank you for sharing your work with us. while training the model i encountered following error.
/usr/local/lib/python3.10/dist-packages/torch/nn/functional.py in cross_entropy(input, target, weight, size_average, ignore_index, reduce, reduction, label_smoothing)
3057 if size_average is not None or reduce is not None:
3058 reduction = _Reduction.legacy_get_string(size_average, reduce)
-> 3059 return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing)

RuntimeError: size mismatch (got input: [6], target: [1])
This error occurred during the second epoch, at approximately 96% completion. It's worth noting that initially, the model was successfully trained for 1 epoch on the CPU without any issues.

Changes Made Before Using the Model
Before training the model, I made changes to some variables at the top of the notebook according to my requirements. These changes included adjusting variables such as label_col, tokens_path, and labels_path. No other modifications were made to the code or the model architecture.

Data Information
My data is structured in a CSV file with two columns: one for the text of the questions and another for the associated labels (levels 1-6). There are a total of 6 classes in the classification, with each text question associated with a specific level in the next column.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions