CNNのPytorch実装

PyTorchを使用したCNNの実装は、以下の手順で行うことができます。
必要なライブラリをインポートします。import torchimport torch.nn as nnimport torch.optim as ...
PyTorchによるrandnでの乱数固定

乱数を発生させる前にtorch.manual_seedを置く
# 直前に置くtorch.manual_seed(42)nn.Parameter(torch.randn(1, 50 + 1, 768))>>Parameter co ...Pytorchでモデルを実装する際のベース [自分用メモ]

BERTをfine-tuningする際のTips [自分用メモ]

AI SHIFT様が作成されたブログ記事が分かりやすかったので、筆者としての解釈を自分用メモとして残すことにする。
Kaggleで学んだBERTをfine-tuningする際のTips①〜学習効率化編〜 | 株式会社AI ...
MLP-Mixerに関する検証用コード

MLP-Mixerに関して、GitHub – rishikksh20/MLP-Mixer-pytorch: Unofficial implementation of MLP-Mixer: An all-MLP Archit ...
Weight Sharering (重み共有)の実装方法 [Pytorch]

Pytorchのチュートリアルから、weight sharering(重み共有)の実装方法を紹介する。
今回扱うのは以下のチュートリアルである。
Learning PyTorch with Examples — ...
ImportError: cannot import name ‘SAVE_STATE_WARNING’ from ‘torch.optim.lr_scheduler’

!pip install torch==1.4.0
ImportError: cannot import name deepcopy のエラーはcopy.pyが原因

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

学習しているとエポックごとの誤差やテストデータセットでのF1 scoreなどを継続的に記録したいと思うことがある.
こんなときにはwriter.add_scalarを使うのが良い.
下記にサンプルコードを載せる ...
UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.

nn.functional.sigmoidは重複しているため、現在のPytorch APIではサポートしていませんよ、という警告。
import torch.nn.functional as Fでインポートし、F.sigmoi ...