# How can I share a pytorch saved model on huggingFace hub

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-can-i-share-a-pytorch-saved-model-on-huggingface-hub%2F17523%3E%5C
**Category:** Beginners\
**Created:** [May 4, 2022, 3:15pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-can-i-share-a-pytorch-saved-model-on-huggingface-hub%2F17523 "2022-05-04T15:15:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivalig94](https://avatars.discourse-cdn.com/v4/letter/i/b782af/32.png) [@ivalig94](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fivalig94)%5C
**Post date:** [May 4, 2022, 3:15pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-can-i-share-a-pytorch-saved-model-on-huggingface-hub%2F17523%2F1 "2022-05-04T15:15:21Z")

</div>

Hello

I have fine-tunned a Roberta-Large model and after fine-tunning i have saved it using torch.save resulting in a .pt file. Now i would like to share my fine-tunned model on huggingFace’s hub, but i need a config.json file and some other files.

i know that these files are given as a result of using model.save\_pretrained, but the problem is that i get an error when i try to execute model.save\_pretrained

Can you help me?

Thanks in advanced

```auto
 class ROBERTAClassifier(PreTrainedModel):
    def __init__ (self, n_classes=3, dropout_rate=0.1):
        super(ROBERTAClassifier, self). __init__ ()
                # Specify hidden size of BERT, hidden size of our classifier, and number of labels
        H=50
        D_out=n_classes
        D_in=1024
        self.roberta = RobertaModel.from_pretrained('roberta-large',return_dict=False)
        self.classifier = nn.Sequential(
        nn.Linear(D_in, D_in),
        nn.Dropout(dropout_rate),
        nn.Linear(D_in, D_out)
        )

    def forward(self, input_ids, attention_mask):
        # Feed input to BERT
        outputs = self.roberta(input_ids=input_ids,attention_mask=attention_mask)
        
        # Extract the last hidden state of the token `[CLS]` for classification task
        last_hidden_state_cls = outputs[0][:, 0, :]

        # Feed input to classifier to compute logits
        logits = self.classifier(last_hidden_state_cls)

        return logits

device = torch.device("cpu")
model=ROBERTAClassifier()
#model= RobertaModel.from_pretrained('roberta-large',return_dict=False)
tokenizer = RobertaTokenizer.from_pretrained('roberta-large')

pt_model = RobertaForSequenceClassification.from_pretrained("path/to/awesome-name-you-picked", from_tf=False)
pt_model.save_pretrained("path/to/awesome-name-you-picked")

model=load_checkpoint(file_path + '/model.pt', model)
model.save_pretrained("my path")

#model=RobertaModel.from_pretrained(file_path + '/model.pt')
#model.from_pretrained(file_path + '/model.pt)`

```
