Spaces:
Build error
Build error
Download model.py from ahamedddd/BERTonSST2Dataset: direct link, hf CLI and curl.
- Browser
- Download file 700 Bytes
-
https://huggingface.co/spaces/ahamedddd/BERTonSST2Dataset/resolve/main/model.py
- Command line
-
hf download hf://spaces/ahamedddd/BERTonSST2Dataset/model.py
-
curl -L -o model.py https://huggingface.co/spaces/ahamedddd/BERTonSST2Dataset/resolve/main/model.py
700 Bytes
| import torch | |
| import torchtext | |
| from torchtext.models import RobertaClassificationHead, XLMR_BASE_ENCODER | |
| from torch import nn | |
| def xlmr_base_encoder_model(num_classes:int=2, # default output classes = 2 (Bad, Good) | |
| ): | |
| transforms = XLMR_BASE_ENCODER.transform() | |
| classifier_head = RobertaClassificationHead(num_classes = 2, input_dim = 768) | |
| model = XLMR_BASE_ENCODER.get_model(head = classifier_head) | |
| for param in model.parameters(): | |
| param.requires_grad = False | |
| return model, transforms | |