Python

Thumbnail of post image 047

F1 scoreを計算する際など,分母にゼロが代入される可能性がある数式を記述する際は,数値リテラルを用いて微小な値を記述するのが便利.

例えば以下のように

def calc_f1(d): d = d/(d + d ...

BERT,Flair

Thumbnail of post image 199

Hugging FaceのTransformersを使って,事前学習済モデルを読み込んで推定させるとタイトルのようなエラーがでることがある.

このエラーはBERTにおけるトークン(サブワード)の最大長512を超えた文が入力 ...

Python,Tensorflow

Thumbnail of post image 173

pip install tensorflow

を実行した際,

ERROR: Could not find a version that satisfies the requirement tensorflow

Flair,Optuna,Python

Thumbnail of post image 074

とある仕事で,固有表現抽出器の性能をぎりぎりまで向上させる必要があったため,自作のコーパスに対してFlairでNERを学習し,Optunaでハイパーパラメータチューニングを行なった.本記事ではそのときのコードを示す.

Em ...

PyTorch

Thumbnail of post image 136

Pytorchで学習したモデルを保存する時は

torch.save(model.state_dict(), model_path)

でモデルを保存することが推奨される.

state_dictがsaveで直接保存す ...

Python,PyTorch

Thumbnail of post image 141

Pytorchを使っている時に出たエラー.これがでたときには,モデルの読み込みの順番でエラーが発生していることが多い.少し順番を変えてあげればケロっとエラーが解消されることが多い.

よくあるエラーが,.load_state ...

Python

Thumbnail of post image 003

エラー

ModuleNotFoundError: No module named ‘flair.embeddings.token’; ‘flair.embeddings’ i ...

Python

Thumbnail of post image 065

スクリプトに一行挿入する.この場合,変数hogeに括弧内以外の文字列が入っているときにエラーをだす.

assert hoge in ("hogeA", "hogeB", "hogeC")

Python

Thumbnail of post image 191

個人的に,入出力をdocoptを記述し,コンフィグ情報はyamlを使って引数として取り込むのが好きなので,そのスクリプトについてメモしておく.decoptの記述では,空行を設けることが重要なので,必要以上に詰めて書かないこと. ...

ELECTRA,Google Cloud Platform,Tensorflow

Thumbnail of post image 197

GCP経由でTPUを利用することによって,ELECTRAの事前学習を実行する方法を紹介.

必要なサービスCompute Engine
Cloud TPU
Cloud Storage
手順Cloud Shell ...