SaiGaneshanM commited on
Commit
91bde62
·
1 Parent(s): b0b9f27

commit files to HF hub

Browse files
Files changed (2) hide show
  1. model.py +22 -0
  2. my_model_weights.h5 +3 -0
model.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import TFAutoModel
2
+ from tensorflow import keras
3
+ import tensorflow as tf
4
+
5
+ class BERTForClassification(keras.Model):
6
+ def __init__(self, bert_model, num_classes):
7
+ super(BERTForClassification, self).__init__()
8
+ self.bert = bert_model
9
+ self.dropout = keras.layers.Dropout(0.3)
10
+ self.classifier = keras.layers.Dense(num_classes, activation="softmax")
11
+
12
+ def call(self, inputs, training=False):
13
+ x = self.bert(inputs)[1] # Pooler output
14
+ x = self.dropout(x, training=training)
15
+ return self.classifier(x)
16
+
17
+ # Load the model
18
+ def load_model():
19
+ bert_model = TFAutoModel.from_pretrained("bert-base-uncased")
20
+ model = BERTForClassification(bert_model, num_classes=2)
21
+ model.load_weights("my_model_weights.h5")
22
+ return model
my_model_weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:969d08cd4e3ea9a5e67ae63c4c3358705cce70570958630f239b5df1ad6ed246
3
+ size 438208152