Pytorchでのログの取り方

学習しているとエポックごとの誤差やテストデータセットでのF1 scoreなどを継続的に記録したいと思うことがある.
こんなときにはwriter.add_scalarを使うのが良い.
下記にサンプルコードを載せる ...
Text mining for processing conditions of solid-state battery electrolytes

Electrochemistry Communications, Dec 2020
材料論文から抽出した処理条件を用いて、固体電解質材料のトレンド分析を行なった。分析では、材料の種類ごとの処理温度帯を可視化したり、分子量対 ...
UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.

nn.functional.sigmoidは重複しているため、現在のPytorch APIではサポートしていませんよ、という警告。
import torch.nn.functional as Fでインポートし、F.sigmoi ...
TransformerでTokenizeしたSpanを入力文から特定

Hugging faceで文をTokenizeすると元の文のSpan情報が失われてしまう。これにより、NERでラベル付けしたトークンの位置をサブワード分割された文の中で見失ってしまうことがある。この困りごとを解決してくれるのが、ret ...
TypeError: iteration over a 0-d tensor

.item()で取り出されたtensorの次元が0のために発生したエラーのため、下記の9から12行目のようにif c.ndim == 0で条件分岐させて対応。
with torch.no_grad(): for data in ...ELMoEmbeddingsのときはallennlp==0.9.0

NLPフレームワークのFlairでELMoの言語モデルを使おうとすると、from flair.embeddings import ELMoEmbeddingsをして関数を呼び出す必要があるのだが、allennlpがインストールされてい ...
なぜBERTの隠れ層の次元が768なのか?

BERTを用いて文や単語から特徴抽出していると、取り出されたベクトルに出現する数字が、バッチサイズを示しているのか、トークン数を示しているのかなどが分からなくなってしまう。見覚えがあるが何の数字だったか混乱した場合は、「BERT 76 ...
WordPress 初期パスワードを表示

cat ./bitnami_credentials
リストの中で最も出現回数の多い要素を取り出す[collection.Counter]

Spacyで文から国名を取得

pip install spacy
python -m spacy download en_core_web_sm
コードimport spacynlp = spacy.load("en_core_web_s ...