aapot commited on
Commit
0074fed
1 Parent(s): f4ac385

Add 1M train step model

Browse files
config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ElectraForPreTraining"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "embedding_size": 768,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 768,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 3072,
13
+ "layer_norm_eps": 1e-12,
14
+ "max_position_embeddings": 512,
15
+ "model_type": "electra",
16
+ "num_attention_heads": 12,
17
+ "num_hidden_layers": 12,
18
+ "pad_token_id": 0,
19
+ "position_embedding_type": "absolute",
20
+ "summary_activation": "gelu",
21
+ "summary_last_dropout": 0.1,
22
+ "summary_type": "first",
23
+ "summary_use_proj": true,
24
+ "torch_dtype": "float32",
25
+ "transformers_version": "4.17.0.dev0",
26
+ "type_vocab_size": 2,
27
+ "use_cache": true,
28
+ "vocab_size": 50265
29
+ }
events.out.tfevents.1644944635.t1v-n-9798b699-w-0 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6effde0ada817c9f414976dd5ecc00424fa01a6891938084c148f735ab06c7b7
3
+ size 31594395
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:624ae7c30d4b5cb961bc5b16849a19dcb607ed3486a97b1b6b653aec80447c64
3
+ size 498665133
tf_rename_checkpoint_variables.py ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Adapted from https://gist.github.com/qqaatw/82b47c2b3da602fa1df604167bfcb9b0
2
+
3
+ import getopt
4
+ import sys
5
+ import re
6
+
7
+ import tensorflow.compat.v1 as tf
8
+
9
+
10
+ usage_str = ('python tensorflow_rename_variables.py '
11
+ '--checkpoint_dir=path/to/dir/ --replace_from=substr '
12
+ '--replace_to=substr --add_prefix=abc --dry_run')
13
+ find_usage_str = ('python tensorflow_rename_variables.py '
14
+ '--checkpoint_dir=path/to/dir/ --find_str=[\'!\']substr')
15
+ comp_usage_str = ('python tensorflow_rename_variables.py '
16
+ '--checkpoint_dir=path/to/dir/ '
17
+ '--checkpoint_dir2=path/to/dir/')
18
+
19
+
20
+ def print_usage_str():
21
+ print('Please specify a checkpoint_dir. Usage:')
22
+ print('%s\nor\n%s\nor\n%s' % (usage_str, find_usage_str, comp_usage_str))
23
+ print('Note: checkpoint_dir should be a *DIR*, not a file')
24
+
25
+
26
+ def compare(checkpoint_dir, checkpoint_dir2):
27
+ import difflib
28
+ with tf.Session():
29
+ list1 = [el1 for (el1, el2) in
30
+ tf.train.list_variables(checkpoint_dir)]
31
+ list2 = [el1 for (el1, el2) in
32
+ tf.train.list_variables(checkpoint_dir2)]
33
+ for k1 in list1:
34
+ if k1 in list2:
35
+ continue
36
+ else:
37
+ print('{} close matches: {}'.format(
38
+ k1, difflib.get_close_matches(k1, list2)))
39
+
40
+
41
+ def find(checkpoint_dir, find_str):
42
+ with tf.Session():
43
+ negate = find_str.startswith('!')
44
+ if negate:
45
+ find_str = find_str[1:]
46
+ for var_name, _ in tf.train.list_variables(checkpoint_dir):
47
+ if negate and find_str not in var_name:
48
+ print('%s missing from %s.' % (find_str, var_name))
49
+ if not negate and find_str in var_name:
50
+ print('Found %s in %s.' % (find_str, var_name))
51
+
52
+
53
+ def rename(checkpoint_dir, replace_from, replace_to, add_prefix, dry_run):
54
+ checkpoint = tf.train.get_checkpoint_state(checkpoint_dir)
55
+ print('print: ', checkpoint)
56
+ with tf.Session() as sess:
57
+ for var_name, _ in tf.train.list_variables(checkpoint_dir):
58
+ # Load the variable
59
+
60
+ var= tf.train.load_variable(checkpoint_dir, var_name)
61
+
62
+ # Set the new name
63
+ if None not in [replace_from, replace_to]:
64
+ new_name = re.sub(replace_from, replace_to, var_name)
65
+ if add_prefix:
66
+ new_name = add_prefix + new_name
67
+ if dry_run:
68
+ print('%s would be renamed to %s.' % (var_name,
69
+ new_name))
70
+ else:
71
+ if var_name != new_name:
72
+ print('Renaming %s to %s.' % (var_name, new_name))
73
+ # Create the variable, potentially renaming it
74
+ var = tf.Variable(var, name=new_name)
75
+
76
+ if not dry_run:
77
+ # Save the variables
78
+ saver = tf.train.Saver()
79
+ sess.run(tf.global_variables_initializer())
80
+ #saver.save(sess, checkpoint.model_checkpoint_path)
81
+ saver.save(sess, "renamed-model.ckpt")
82
+
83
+
84
+ def main(argv):
85
+ checkpoint_dir = None
86
+ checkpoint_dir2 = None
87
+ replace_from = None
88
+ replace_to = None
89
+ add_prefix = None
90
+ dry_run = False
91
+ find_str = None
92
+
93
+ try:
94
+ opts, args = getopt.getopt(argv, 'h', ['help=', 'checkpoint_dir=',
95
+ 'replace_from=', 'replace_to=',
96
+ 'add_prefix=', 'dry_run',
97
+ 'find_str=',
98
+ 'checkpoint_dir2='])
99
+ except getopt.GetoptError as e:
100
+ print(e)
101
+ print_usage_str()
102
+ sys.exit(2)
103
+ for opt, arg in opts:
104
+ if opt in ('-h', '--help'):
105
+ print(usage_str)
106
+ sys.exit()
107
+ elif opt == '--checkpoint_dir':
108
+ checkpoint_dir = arg
109
+ elif opt == '--checkpoint_dir2':
110
+ checkpoint_dir2 = arg
111
+ elif opt == '--replace_from':
112
+ replace_from = arg
113
+ elif opt == '--replace_to':
114
+ replace_to = arg
115
+ elif opt == '--add_prefix':
116
+ add_prefix = arg
117
+ elif opt == '--dry_run':
118
+ dry_run = True
119
+ elif opt == '--find_str':
120
+ find_str = arg
121
+
122
+ if not checkpoint_dir:
123
+ print_usage_str()
124
+ sys.exit(2)
125
+
126
+ if checkpoint_dir2:
127
+ compare(checkpoint_dir, checkpoint_dir2)
128
+ elif find_str:
129
+ find(checkpoint_dir, find_str)
130
+ else:
131
+ rename(checkpoint_dir, replace_from, replace_to, add_prefix, dry_run)
132
+
133
+
134
+ if __name__ == '__main__':
135
+ main(sys.argv[1:])