rishikasrinivas commited on
Commit
86341ce
·
verified ·
1 Parent(s): a3b2a61

Create push_to_hub.py

Browse files
Files changed (1) hide show
  1. push_to_hub.py +17 -0
push_to_hub.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ from huggingface_hub import PyTorchModelHubMixin
4
+ from model import BERT
5
+
6
+ # create model
7
+ config = {"num_channels": 3, "hidden_size": 32, "num_classes": 10}
8
+ model = BERT()
9
+
10
+ # save locally
11
+ model.save_pretrained("genre-pred")
12
+
13
+ # push to the hub
14
+ model.push_to_hub("genre-pred")
15
+
16
+ # reload
17
+ model = MyModel.from_pretrained("rishikasrinivas/genre-pred")