2df9a66ac40d1017792b1c93f34e47e214726d7d,demo/load_model/load_and_pool.py,,,#,9
Before Change
model = keras.models.Model(inputs=model.inputs, outputs=pool_layer)
model.summary(line_length=120)
tokens = ["[CLS]", "语", "言", "模", "型", "[SEP]"]
token_dict = {}
with codecs.open(dict_path, "r", "utf8") as reader:
for line in reader:
token = line.strip()
token_dict[token] = len(token_dict)
token_input = np.asarray([[token_dict[token] for token in tokens] + [0] * (512 - len(tokens))])
seg_input = np.asarray([[0] * len(tokens) + [0] * (512 - len(tokens))])
print("Inputs:", token_input[0][:len(tokens)])
After Change
text = "语言模型"
tokens = tokenizer.tokenize(text)
print("Tokens:", tokens)
indices, segments = tokenizer.encode(first="语言模型", max_len=512)
predicts = model.predict([np.array([indices]), np.array([segments])])[0]
print("Pooled:", predicts.tolist()[:5])
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
Instances
Project Name: CyberZHG/keras-bert
Commit Name: 2df9a66ac40d1017792b1c93f34e47e214726d7d
Time: 2019-03-18
Author: CyberZHG@gmail.com
File Name: demo/load_model/load_and_pool.py
Class Name:
Method Name:
Project Name: ray-project/ray
Commit Name: ef498e8aa5cdfe09247d9c9efc7ef636378165c2
Time: 2020-05-15
Author: ed.nmi.oakes@gmail.com
File Name: python/ray/serve/policy.py
Class Name: PowerOfTwoPolicy
Method Name: flush
Project Name: CyberZHG/keras-bert
Commit Name: 2df9a66ac40d1017792b1c93f34e47e214726d7d
Time: 2019-03-18
Author: CyberZHG@gmail.com
File Name: demo/load_model/load_and_extract.py
Class Name:
Method Name: