# lab関連 ###### tags: `keio` - [これなら分かる深層学習入門](https://) ## 疑問 - 0824 - KLのマイナス、MSEとcrossentropyの違い(VAE) - VAEはcross entropyなのか - 0825 - validationも行う ## 心得 - 2回もしくは20分悩んだら質問をする - 論文の他手法は、今回手法との比較点は最低把握しておく - 手法の入力、出力が何かを常に意識する - 進捗報告では過去の状況、今回改善したことを記述する ## ssh - windowsからmacを経由して研究室PCにアクセスする方法 1. `ssh kusumotokaito@192.168.99.30` - アクセスできない時は最後に改行しているか確認する 3. `ssh -Y -p 10022 kusumoto@gw.murata.elec.keio.ac.jp` 4. `ssh -Y kusumoto@gf-rtx3080-2.local` 5. `cd ~/Documents/lab-git;pipenv shell;cd ~/Documents/lab-git/study/RNN_from_framework/ctrnn;jupyter notebook` - [長時間計算回したい(DNNの学習とか)けどssh張りっぱなしは嫌なんですが...](https://blog.neno.dev/entry/2020/06/11/193403#tmux) ## python ## jupyter - jsonのままjupyterが開かない場合[link](https://bleepcoder.com/ja/vscode-jupyter/747213373/unable-to-open-jupyter-notebooks-using-the-jupyter-notebook) - setting.jsonを変更をする - .py上からjupyterを使用することも可能[link](https://qiita.com/386jp/items/f023de9457c99b964a85) ## 数式 - [リサジュー図形の式](http://www.ne.jp/asahi/tokyo/nkgw/www_2/gakusyu/rikigaku/Lissajous/Lissajous_kaisetu/Lissajous_kaisetu_1.html) - リサージュ曲線の位相の関係 ## 確率関連 - [1. Pythonで学ぶ統計学 2. 確率分布[scipy.stats徹底理解]](https://qiita.com/y_itoh/items/c388ff82360906240daf) - [【訓練誤差と汎化誤差】学習・統計的推定は正しいのか?【過学習】](https://www.hellocybernetics.tech/entry/2019/09/28/160024) - [リッジ回帰とラッソ回帰の理論と実装を初めから丁寧に](https://qiita.com/Takayoshi_Makabe/items/8f6dcb25124b9dcb1ae8) - [機械学習のための確率基礎とベイズの定理](https://www.hellocybernetics.tech/entry/2016/10/05/163856) ## 機械学習 - [「End-to-end training」 とは?](https://teratail.com/questions/124187) - End-to-End学習とは端つまり入力と出力だけ渡して、途中で発生する処理全てを学習してしまうというもの。 OCRを例に挙げると、入力の画像から途中の処理を細かいタスクに分け最終的に文字認識に到るという構造が 一般的、しかしEnd-to-End学習では中間の処理も全て学習させる。 注意点としてデータセットがたくさん必要になる点、逆に言うとデータセットが少ないなら今までの手法を使えばよい。 ## 深層学習 - 層の数 ## ベイズ - [変分ベイズ法の説明](https://www.slideshare.net/yuifu/ss-49489128) ## バッチ学習 - [第26話 バックプロパゲーションの理解に必要な知識 -バッチサイズ-](https://note.com/yeahyeahoh/n/nb979ed7e9cb8) - [【人工知能】機械学習で行われる学習方法について。バッチ・ミニバッチ・オンライン学習。](https://fresopiya.com/2019/05/24/batchlearning/) ## VAE - [Variational Autoencoder徹底解説](https://qiita.com/kenmatsu4/items/b029d697e9995d93aa24) - [Variational AutoEncoder( VAE )](https://blog.octopt.com/variational-autoencoder/) - [教師なし機械学習「VAE」による連続的な手書き文字の生成](https://rightcode.co.jp/blog/information-technology/unsupervised-learning-vae-continuous-handwriting-generation) - [★【お気持ちシリーズ】VAEはEMと変分ベイズの亜種だ!](https://academ-aid.com/okimochi-vae) - [](https://towardsdatascience.com/variational-autoencoder-demystified-with-pytorch-implementation-3a06bee395ed) - [](https://lilianweng.github.io/lil-log/2018/08/12/from-autoencoder-to-beta-vae.html) - [多変量正規分布の場合のKullback Leibler Divergenceの導出](https://aidiary.hatenablog.com/entry/20180228/1519828344) - [KL pytorchでの実装式](https://github.com/jojonki/AutoEncoders/blob/master/VAE.pdf) - [PyTorch (11) Variational Autoencoder](https://aidiary.hatenablog.com/entry/20180228/1519828344) - [【超初心者向け】VAEの分かりやすい説明とPyTorchの実装 ※様々な質問あり](https://tips-memo.com/vae-pytorch) - [再構成誤差](https://atcold.github.io/pytorch-Deep-Learning/ja/week07/07-3/) - [](https://lilianweng.github.io/lil-log/2018/08/12/from-autoencoder-to-beta-vae.html) - [Variational AutoEncoders (VAE) with PyTorch](https://avandekleut.github.io/vae/) - [A Variational Autoencoder on the SVHN dataset](https://bjlkeng.github.io/posts/a-variational-autoencoder-on-the-svnh-dataset/) ### mmvae - [How I learned to stop worrying and write ELBO (and its gradients) in a billion ways](https://yugeten.github.io/posts/2020/06/elbo/) ### vrae - [timeseries-clustering-vae](https://github.com/tejaslodaya/timeseries-clustering-vae) ## keras ### basic use - [python:__call__メソッドの基礎](https://note.com/tamurasann/n/n9c1692a39352) - callと__call__の違いは? - callメソッドが分からない。Denseは__call__だったのにSimpleRNNはcallになっている。 - [Model training APIs](https://keras.io/api/models/model_training_apis/) - fitとか - [Character-level recurrent sequence-to-sequence model](https://keras.io/examples/nlp/lstm_seq2seq/) - データの次元について - (バッチサイズ、サンプル数、入力次元) - 4/7 sample_rnnについて - モデルで249データ数学習をしてから、入力&出力データ数1のモデルを作成し、重みをgetsetで反映してから[1,1,2]入力[1,1,2]出力のpredictをする - [keras tutorial](https://www.tensorflow.org/guide/keras/functional) ### save - [Kerasモデルの保存と読み込み](https://www.tensorflow.org/guide/keras/save_and_serialize?hl=ja) ### 結合、次元追加 - [tf.concat](https://www.tensorflow.org/api_docs/python/tf/concat) - [tf.expand_dims](https://www.tensorflow.org/api_docs/python/tf/expand_dims) ### random seedの固定方法 - [[TensorFlow 2.x (tf.keras)] 乱数シードを固定して再現性を向上](https://qiita.com/bee2/items/08eab7a899c9ff56eb35) ### subclass vs functional - [What are Symbolic and Imperative APIs in TensorFlow 2.0?](https://blog.tensorflow.org/2019/01/what-are-symbolic-and-imperative-apis.html) - [Tensorflow2(Sequential API, Functional API, Subclassing API)とMNISTではじめる画像分類](https://qiita.com/hiro871_/items/8e8fd65c28d1e2a13fa9) ### subclass(custom layers) - [Making new Layers and Models via subclassing](https://www.tensorflow.org/guide/keras/custom_layers_and_models) - ここにzero_grad的な手法も記載されている - tf.keras.layer.Layersではなくtf.keras.Modelで作成するとcompileできる ### weight - [tf.keras 流な weight 宣言の方法と罠](https://qiita.com/halhorn/items/e9a0bb8ebdbadabc17b9) - tensorflow2以降はtf.Variable()ではなくtf.add_variableで重みを宣言する ### grad - https://keras.io/api/optimizers/ ## pytorch ### install - [[PyTorch] Windows10 + Pipenv で PyTorch(GPU)を導入する](https://qiita.com/Haaamaaaaa/items/69b30d1dbbfcea834a9d) - [pipenvでpytorch@python3.8環境構築](https://qiita.com/utom/items/d349ab87cd025f8391d1) - `pip3 install https://download.pytorch.org/whl/nightly/cu111/torch-1.9.0.dev20210530%2Bcu111-cp38-cp38-linux_x86_64.whl` ### [PYTORCH DOCUMENTATION](https://pytorch.org/docs/stable/index.html) - [torchvisionのtransformsが分からなかったので調べた。](https://tasotasoso.hatenablog.com/entry/2020/01/12/184130?utm_source=feed) - [pyTorchのTensor型とは](https://qiita.com/mathlive/items/241bfb42d852bb801b96) - [pyTorchのtransforms,Datasets,Dataloaderの説明と自作Datasetの作成と使用](https://qiita.com/mathlive/items/2a512831878b8018db02) - [【PyTorch】torch.stackをいろいろと検証とニューラルネットに入力する画像データの考察](https://panda-clip.com/torch-stack/) - [【PyTorch】Tensorを操作する関数(transpose、view、reshape)](https://qiita.com/kenta1984/items/d68b72214ce92beebbe2) - [TORCH.TENSOR](https://pytorch.org/docs/stable/tensors.html#torch.Tensor.permute) - [軸の増やし方](https://qiita.com/SZZZUJg97M/items/f416269a2a9dc114da75) - [TORCH.SQUEEZE](https://pytorch.org/docs/stable/generated/torch.squeeze.html) - Returns a tensor with all the dimensions of input of size 1 removed. - [Taking an optimization step](https://pytorch.org/docs/stable/optim.html#taking-an-optimization-step) - All optimizers implement a step() method, that updates the parameters. - [NO_GRAD](https://pytorch.org/docs/stable/generated/torch.no_grad.html#torch.no_grad) - Context-manager that disabled gradient calculation. - backwardを行わない前提。計算量の削減(requires_grad=False状態にする) - [torch.nn.module.eval()](https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module) - Sets the module in evaluation mode. - [torch.nn.Module.train](https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module.train)と同じ - dropout, batchnormなどはtrainとevaluationで挙動が変わるため - [torch.Tensor.argmax](https://pytorch.org/docs/stable/tensors.html#torch.Tensor.argmax) - 最大値をとるインデックスを返す。dim(int)を指定することで削除する次元を指定 - [pyTorchのNetworkのパラメータの閲覧と書き換え](https://qiita.com/mathlive/items/d9f31f8538e20a102e14) - [torch.dotとtorch.mmとtorch.mvとtorch.bmmとtorch.matmulを比較する](https://qiita.com/tand826/items/9e1b6a4de785097fe6a5) - [Pytorch tensor と numpy ndarray の変換](https://tzmi.hatenablog.com/entry/2020/02/16/170928) - [Pytorch基本メモ (主にtorchとtorch.aurograd.Variable)](https://www.hellocybernetics.tech/entry/2017/10/07/013937) ### torch.distribution - [PROBABILITY DISTRIBUTIONS - TORCH.DISTRIBUTIONS](https://pytorch.org/docs/stable/distributions.html) ### dataloader, dataset - [pyTorchのtransforms,Datasets,Dataloaderの説明と自作Datasetの作成と使用](https://qiita.com/mathlive/items/2a512831878b8018db02) - [](https://tips-memo.com/pytorch-dataset) - (https://qiita.com/makaishi2/items/3676d216fe9b34b63430) - [PytorchのDatasetを徹底解説(自作データセットも作れる)](https://dreamer-uma.com/pytorch-dataset/) - [【徹底解説】PytorchのDataLoaderの使い方](https://dreamer-uma.com/pytorch-dataloader/) #### cross entropy - [Expected input batch_size (1) to match target batch_size (6).のエラーを直したいです.](https://qiita.com/Haaamaaaaa/items/58ba0962a8fcd1eeb82e) - [[PyTorch]CrossEntropyLossを数式入りでちょっと理解する](https://qiita.com/Haaamaaaaa/items/58ba0962a8fcd1eeb82e) #### バッチ学習 - [pytorch: “multi-target not supported” error message](https://stackoverflow.com/questions/57325844/pytorch-multi-target-not-supported-error-message) ### ラベル付け - [One-Hotエンコーディング(ダミー変数)ならPandasのget_dummies()を使おう](https://blog.shikoan.com/pandas-get-dummies/) ### CNN - [Conv2d](https://pytorch.org/docs/stable/generated/torch.nn.Conv2d.html#torch.nn.Conv2d) - torch.nn.Conv2 - in_channels:入力チャンネル数 - out_channels:出力チャンネル数 - kernel_size:H×Hのフィルタの幅H - stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros' ### RNN - [torch.nn > RNN](https://pytorch.org/docs/stable/generated/torch.nn.RNN.html) - input - input of shape (seq_len, batch, input_size): tensor containing the features of the input sequence. The input can also be a packed variable length sequence. See torch.nn.utils.rnn.pack_padded_sequence() or torch.nn.utils.rnn.pack_sequence() for details. - h_0 - h_0 of shape (num_layers * num_directions, batch, hidden_size): tensor containing the initial hidden state for each element in the batch. Defaults to zero if not provided. If the RNN is bidirectional, num_directions should be 2, else it should be 1. - [PyTorch: RNNとRNNCellの違い](https://scrapbox.io/programming-notes/PyTorch:_RNN%E3%81%A8RNNCell%E3%81%AE%E9%81%95%E3%81%84) - [torch.nn.LSTM](https://pytorch.org/docs/stable/generated/torch.nn.LSTM.html#torch.nn.LSTM) - [torch.nn.LSTMCell](https://pytorch.org/docs/stable/generated/torch.nn.LSTMCell.html#torch.nn.LSTMCell) - [LSTMネットワークの概要](https://qiita.com/KojiOhki/items/89cd7b69a8a6239d67ca) - [ctrnn github参考](https://github.com/tomekkorbak/mtrnn) ### エラーQ&A - Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! - to(device)がすべてに適用されていない。 - torch.set_default_tensor_type('torch.cuda.FloatTensor') で解決 - Error: Direct kernel connection broken - torch.set_default_tensor_type('torch.cuda.FloatTensor') で解決 - 普通のエラーが出ずにカーネルが破壊されてしまう。困った。。。 ## PCA - [主成分分析とは?簡単な説明とPythonでの実装!](https://toukei-lab.com/pca) ## 論文メモ - LEARNING TO DIAGNOSE WITH LSTM RECURRENT NEURAL NETWORKS - A Hierarchical Latent Variable Encoder-Decoder Model for Generating Dialogues - TOPICRNN: A RECURRENT NEURAL NETWORK WITH LONG-RANGE SEMANTIC DEPENDENCY - Multimodal Deep Learning for Mental Disorders Prediction from Audio Speech Samples - マルチモーダル - Deep Multi-task Learning for Depression Detection and Prediction in Longitudinal Data - Explainable Depression Detection with Multi-Modalities Using a Hybrid Deep Learning Model on Social Media - Deep Sequential Models for Suicidal Ideation from Multiple Source Data - Verifying Design through Generative Visualization of Neural Activities - A study of latent monotonic attention variants - DRAW: A Recurrent Neural Network For Image Generation - A Novel Predictive-Coding-Inspired Variational RNN