Python

Thumbnail of post image 143
elems = c = collections.Counter(elems)l = list(c.keys())selected = lprint(selected)>>a

Python

Thumbnail of post image 048

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

例えば以下のように

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

Python,Tensorflow

Thumbnail of post image 034

pip install tensorflow

を実行した際,

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

Flair,Optuna,Python

Thumbnail of post image 160

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

Em ...

Python,PyTorch

Thumbnail of post image 195

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

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

Python

Thumbnail of post image 119

エラー

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

Python

Thumbnail of post image 178

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

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

Python

Thumbnail of post image 057

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

Flair,Python

Thumbnail of post image 012

FlairでNERを実施した際,training.logというのが出力されるのだが,これにはmicro F1は載っているが,micro recallとprecisionは載っていない.このため,ログファイルからTP, FP, FNを読 ...

Python

Thumbnail of post image 188

生データを処理しているとよく遭遇する複数のスペースを含む文章.

2つ以上のスペースを1つにしたいときは以下のコマンド

' '.join(mystring.split())