PIL,Python

Thumbnail of post image 107

PILを使っていると発生するこのエラーは以下をコードの冒頭に追加することで解決。

from PIL import ImageFileImageFile.LOAD_TRUNCATED_IMAGES = True

こうすることに ...

Python,PyTorch

Thumbnail of post image 101

pytorchのモデルを書いていて、何度かテストしていたのだが、突然、ImportError: cannot import name deepcopy というエラーがでて戸惑う。「torch ImportError: cannot i ...

Python

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

Python

Thumbnail of post image 100

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

例えば以下のように

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

Python,Tensorflow

Thumbnail of post image 021

pip install tensorflow

を実行した際,

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

Flair,Optuna,Python

Thumbnail of post image 006

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

Em ...

Python,PyTorch

Thumbnail of post image 003

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

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

Python

Thumbnail of post image 009

エラー

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

Python

Thumbnail of post image 190

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

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