ydshieh commited on
Commit
c6bc350
1 Parent(s): 26f5967

initial commit

Browse files
config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "n_layers": 2,
3
+ "model_type": "my_model",
4
+ "auto_map": {
5
+ "AutoConfig": "configuration_my_model.MyModelConfig",
6
+ "AutoModel": "modeling_my_model.MyModel"
7
+ }
8
+ }
configuration_my_model.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import PretrainedConfig
2
+
3
+
4
+ class MyModelConfig(PretrainedConfig):
5
+ model_type = "my_model"
6
+
7
+ def __init__(
8
+ self,
9
+ n_layers=2,
10
+ hidden_dim=3,
11
+ **kwargs,
12
+ ):
13
+ self.n_layers = n_layers
14
+ self.hidden_dim = hidden_dim
15
+ super().__init__(**kwargs)
modeling_tf_my_model.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+
3
+ from transformers.modeling_tf_utils import TFPreTrainedModel
4
+
5
+ from configuration_my_model import MyModelConfig
6
+
7
+
8
+ class TFMyModelPretrainedModel(TFPreTrainedModel):
9
+ config_class = MyModelConfig
10
+
11
+
12
+ class TFMyModel(TFMyModelPretrainedModel):
13
+
14
+ def __init__(self, config: MyModelConfig):
15
+ super().__init__(config)
16
+ self.config = config
17
+
18
+ self.n_layers = config.n_layers
19
+ self.hidden_dim = config.hidden_dim
20
+ self.linear = tf.keras.layers.Dense(units=config.n_layers)
21
+
22
+
23
+ config = MyModelConfig()
24
+ model = TFMyModel(config)
25
+ print(model)
26
+ model.save_pretrained("my_model")
tf_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ea321f2d474594e3bb8b6e200ca03881ecaca86aafd693b930d1713c49563d4
3
+ size 7120