Skip to content

Instantly share code, notes, and snippets.

View amar-enkhbat's full-sized avatar

Amar Enkhbat amar-enkhbat

  • Nijmegen, Netherlands
View GitHub Profile
from transformers import DistilBertModel
from transformers import AlbertTokenizer
from transformers import DistilBertForQuestionAnswering
import torch
# Load model
pt_model = DistilBertModel.from_pretrained('laboro-ai/distilbert-base-japanese')
sp_tokenizer = AlbertTokenizer.from_pretrained('laboro-ai/distilbert-base-japanese')
model = DistilBertForQuestionAnswering.from_pretrained('laboro-ai/distilbert-base-japanese-finetuned-ddqa')
@amar-enkhbat
amar-enkhbat / problem_9.py
Created July 11, 2019 12:45
演習問題9
import numpy as np
def calc_H_and_L(result):
log_side = np.log2(1./result)
ceil_log_side = np.ceil(log_side)
H = np.sum(result * log_side)
L = np.sum(result * ceil_log_side)
return H, L, ceil_log_side
probs = np.array([1/3, 1/4, 5/12])
@amar-enkhbat
amar-enkhbat / problem_7.py
Last active July 11, 2019 12:46
演習問題7
import numpy as np
probs = np.array([0.3, 0.2, 0.15, 0.15, 0.1, 0.1])
result = np.array([])
for prob in probs:
result = np.append(result, probs * prob)
print(result)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.