MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / NestedModel

Class NestedModel

SwissArmyTransformer/tests/test_nested_model.py:5–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import json, os
4
5class NestedModel(BaseModel):
6 def __init__(self, args, *argv, **kwargs):
7 super().__init__(args, *argv, **kwargs)
8 self.net = BertModel(BertModel.get_args(
9 **args.bert_args
10 ))
11
12 @classmethod
13 def add_model_specific_args(cls, parser):
14 group = parser.add_argument_group('Nested Example', 'Nested Example Configurations')
15 group.add_argument('--bert_args', type=json.loads, default={}, help='Bert Model Arguments')
16 return parser
17
18 @BaseMixin.non_conflict
19 def word_embedding_forward_default(self, input_ids, output_cross_layer, old_impl, **kw_args):
20 return old_impl(input_ids, **kw_args) + self.net(input_ids, input_ids,input_ids)
21
22def test_create():
23 a = NestedModel(args=NestedModel.get_args(num_layers=2,

Callers 2

test_createFunction · 0.85
test_save_and_loadFunction · 0.85

Calls

no outgoing calls

Tested by 2

test_createFunction · 0.68
test_save_and_loadFunction · 0.68