Skip to content

Commit

Permalink
Update_GAN_and_HW5
Browse files Browse the repository at this point in the history
  • Loading branch information
Fafa-DL committed Apr 9, 2021
1 parent 0ce0aa3 commit 744f777
Show file tree
Hide file tree
Showing 27 changed files with 13,684 additions and 4,539 deletions.

Large diffs are not rendered by default.

5,402 changes: 2,701 additions & 2,701 deletions 01 Introduction/代码/covid.train.csv → 01 Introduction/作业HW1/covid.train.csv

Large diffs are not rendered by default.

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2,400 changes: 2,400 additions & 0 deletions 06 GAN/作业HW5/HW05.ipynb

Large diffs are not rendered by default.

Binary file added 06 GAN/作业HW5/HW05.pdf
Binary file not shown.
2,401 changes: 2,401 additions & 0 deletions 06 GAN/作业HW5/HW05_ZH.ipynb

Large diffs are not rendered by default.

Binary file added 06 GAN/课件/gan_v9.pdf
Binary file not shown.
Binary file added 06 GAN/课件/gan_v9.pptx
Binary file not shown.
9 changes: 6 additions & 3 deletions 范例/HW01/HW01.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"provenance": [],
"collapsed_sections": [],
"toc_visible": true,
"authorship_tag": "ABX9TyMsVwxzy9cP7RXmbb8AmT4Y",
"authorship_tag": "ABX9TyPuibV8rME8Y2Er3TVnCm93",
"include_colab_link": true
},
"kernelspec": {
Expand Down Expand Up @@ -45,7 +45,10 @@
"Author: Heng-Jui Chang\n",
"\n",
"Slides: https://github.com/ga642381/ML2021-Spring/blob/main/HW01/HW01.pdf \n",
"Video: TBA\n",
"Videos (Mandarin): https://cool.ntu.edu.tw/courses/4793/modules/items/172854 \n",
"https://cool.ntu.edu.tw/courses/4793/modules/items/172853 \n",
"Video (English): https://cool.ntu.edu.tw/courses/4793/modules/items/176529\n",
"\n",
"\n",
"Objectives:\n",
"* Solve a regression problem with deep neural networks (DNN).\n",
Expand Down Expand Up @@ -378,7 +381,7 @@
"\n",
" def cal_loss(self, pred, target):\n",
" ''' Calculate loss '''\n",
" # TODO: you may implement L2 regularization here\n",
" # TODO: you may implement L1/L2 regularization here\n",
" return self.criterion(pred, target)"
],
"execution_count": null,
Expand Down
6 changes: 5 additions & 1 deletion 范例/HW02/HW02-1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
"id": "OYlaRwNu7ojq"
},
"source": [
"# **Homework 2-1 Phoneme Classification**"
"# **Homework 2-1 Phoneme Classification**\n",
"\n",
"* Slides: https://speech.ee.ntu.edu.tw/~hylee/ml/ml2021-course-data/hw/HW02/HW02.pdf\n",
"* Video (Chinese): https://youtu.be/PdjXnQbu2zo\n",
"* Video (English): https://youtu.be/ESRr-VCykBs\n"
]
},
{
Expand Down
77 changes: 40 additions & 37 deletions 范例/HW02/HW02-2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@
"id": "eNSV4QGHS1I1"
},
"source": [
"# **Homework 2-2 Hessian Matrix**\r\n",
"\r\n"
"# **Homework 2-2 Hessian Matrix**\n",
"\n",
"* Slides: https://speech.ee.ntu.edu.tw/~hylee/ml/ml2021-course-data/hw/HW02/HW02.pdf\n",
"* Video (Chinese): https://youtu.be/PdjXnQbu2zo\n",
"* Video (English): https://youtu.be/ESRr-VCykBs\n"
]
},
{
Expand Down Expand Up @@ -171,7 +174,7 @@
"id": "ZFGBCIFmVLS_"
},
"source": [
"### Import Libraries\r\n"
"### Import Libraries\n"
]
},
{
Expand All @@ -180,16 +183,16 @@
"id": "_-vjBvH0uqA-"
},
"source": [
"import numpy as np\r\n",
"from math import pi\r\n",
"from collections import defaultdict\r\n",
"from autograd_lib import autograd_lib\r\n",
"\r\n",
"import torch\r\n",
"import torch.nn as nn\r\n",
"from torch.utils.data import DataLoader, Dataset\r\n",
"\r\n",
"import warnings\r\n",
"import numpy as np\n",
"from math import pi\n",
"from collections import defaultdict\n",
"from autograd_lib import autograd_lib\n",
"\n",
"import torch\n",
"import torch.nn as nn\n",
"from torch.utils.data import DataLoader, Dataset\n",
"\n",
"import warnings\n",
"warnings.filterwarnings(\"ignore\")"
],
"execution_count": null,
Expand All @@ -212,17 +215,17 @@
"id": "uvdOpR9lVaJQ"
},
"source": [
"class MathRegressor(nn.Module):\r\n",
" def __init__(self, num_hidden=128):\r\n",
" super().__init__()\r\n",
" self.regressor = nn.Sequential(\r\n",
" nn.Linear(1, num_hidden),\r\n",
" nn.ReLU(),\r\n",
" nn.Linear(num_hidden, 1)\r\n",
" )\r\n",
"\r\n",
" def forward(self, x):\r\n",
" x = self.regressor(x)\r\n",
"class MathRegressor(nn.Module):\n",
" def __init__(self, num_hidden=128):\n",
" super().__init__()\n",
" self.regressor = nn.Sequential(\n",
" nn.Linear(1, num_hidden),\n",
" nn.ReLU(),\n",
" nn.Linear(num_hidden, 1)\n",
" )\n",
"\n",
" def forward(self, x):\n",
" x = self.regressor(x)\n",
" return x"
],
"execution_count": null,
Expand Down Expand Up @@ -297,12 +300,12 @@
"id": "OSU8vnXEbY6q"
},
"source": [
"# load checkpoint and data corresponding to the key\r\n",
"model = MathRegressor()\r\n",
"autograd_lib.register(model)\r\n",
"\r\n",
"data = torch.load('data.pth')[key]\r\n",
"model.load_state_dict(data['model'])\r\n",
"# load checkpoint and data corresponding to the key\n",
"model = MathRegressor()\n",
"autograd_lib.register(model)\n",
"\n",
"data = torch.load('data.pth')[key]\n",
"model.load_state_dict(data['model'])\n",
"train, target = data['data']"
],
"execution_count": null,
Expand Down Expand Up @@ -490,13 +493,13 @@
"id": "1X-2uxwTcB9u"
},
"source": [
"# the main function to compute gradient norm and minimum ratio\r\n",
"def main(model, train, target):\r\n",
" criterion = nn.MSELoss()\r\n",
"\r\n",
" gradient_norm = compute_gradient_norm(model, criterion, train, target)\r\n",
" minimum_ratio = compute_minimum_ratio(model, criterion, train, target)\r\n",
"\r\n",
"# the main function to compute gradient norm and minimum ratio\n",
"def main(model, train, target):\n",
" criterion = nn.MSELoss()\n",
"\n",
" gradient_norm = compute_gradient_norm(model, criterion, train, target)\n",
" minimum_ratio = compute_minimum_ratio(model, criterion, train, target)\n",
"\n",
" print('gradient norm: {}, minimum ratio: {}'.format(gradient_norm, minimum_ratio))"
],
"execution_count": null,
Expand Down
31 changes: 22 additions & 9 deletions 范例/HW04/HW04.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@
"- Baselines:\n",
" - Easy: Run sample code and know how to use transformer.\n",
" - Medium: Know how to adjust parameters of transformer.\n",
" - Hard: Construct [conformer](https://arxiv.org/abs/2005.08100) which is a variety of transformer. "
" - Hard: Construct [conformer](https://arxiv.org/abs/2005.08100) which is a variety of transformer. \n",
"\n",
"- Other links\n",
" - Kaggle: [link](https://www.kaggle.com/t/859c9ca9ede14fdea841be627c412322)\n",
" - Slide: [link](https://speech.ee.ntu.edu.tw/~hylee/ml/ml2021-course-data/hw/HW04/HW04.pdf)\n",
" - Data: [link](https://drive.google.com/file/d/1T0RPnu-Sg5eIPwQPfYysipfcz81MnsYe/view?usp=sharing)\n",
" - Video (Chinese): [link](https://www.youtube.com/watch?v=EPerg2UnGaI)\n",
" - Video (English): [link](https://www.youtube.com/watch?v=Gpz6AUvCak0)\n",
" - Solution for downloading dataset fail.: [link](https://drive.google.com/drive/folders/13T0Pa_WGgQxNkqZk781qhc5T9-zfh19e?usp=sharing)"
]
},
{
Expand All @@ -36,7 +44,10 @@
"id": "TPDoreyypeJE"
},
"source": [
"# Download dataset"
"# Download dataset\n",
"- **If all download links fail**\n",
"- **Please follow [here](https://drive.google.com/drive/folders/13T0Pa_WGgQxNkqZk781qhc5T9-zfh19e?usp=sharing)**\n",
"- **Data is [here](https://drive.google.com/file/d/1T0RPnu-Sg5eIPwQPfYysipfcz81MnsYe/view?usp=sharing)**"
]
},
{
Expand All @@ -63,8 +74,10 @@
"# !gdown --id '1MUGBvG_JjqO0C2JYHuyV3B0lvaf1kWIm' --output Dataset.zip\n",
"\"\"\" Download link 7 of Google drive \"\"\"\n",
"# !gdown --id '18M91P5DHwILNyOlssZ57AiPOR0OwutOM' --output Dataset.zip\n",
"\"\"\" For all download links fail, Please paste link into 'Paste link here' \"\"\"\n",
"# !gdown --id 'Paste link here' --output Dataset.zip\n",
"\"\"\" For Google drive, you can unzip the data by the command below. \"\"\"\n",
"# !unzip Dataset.zip\n",
"!unzip Dataset.zip\n",
"\n",
"\"\"\"\n",
" For Dropbox, we split dataset into five files. \n",
Expand All @@ -82,12 +95,12 @@
" For Onedrive, we split dataset into five files. \n",
" Please download all of them.\n",
"\"\"\"\n",
"!wget --no-check-certificate \"https://onedrive.live.com/download?cid=10C95EE5FD151BFB&resid=10C95EE5FD151BFB%21106&authkey=ACB6opQR3CG9kmc\" -O Dataset.tar.gz.aa\n",
"!wget --no-check-certificate \"https://onedrive.live.com/download?cid=93DDDDD552E145DB&resid=93DDDDD552E145DB%21106&authkey=AP6EepjxSdvyV6Y\" -O Dataset.tar.gz.ab\n",
"!wget --no-check-certificate \"https://onedrive.live.com/download?cid=644545816461BCCC&resid=644545816461BCCC%21106&authkey=ALiefB0kI7Epb0Q\" -O Dataset.tar.gz.ac\n",
"!wget --no-check-certificate \"https://onedrive.live.com/download?cid=77CEBB3C3C512821&resid=77CEBB3C3C512821%21106&authkey=AAXCx4TTDYC0yjM\" -O Dataset.tar.gz.ad\n",
"!wget --no-check-certificate \"https://onedrive.live.com/download?cid=383D0E0146A11B02&resid=383D0E0146A11B02%21106&authkey=ALwVc4StVbig6QI\" -O Dataset.tar.gz.ae\n",
"!cat Dataset.tar.gz.* | tar zxvf -"
"# !wget --no-check-certificate \"https://onedrive.live.com/download?cid=10C95EE5FD151BFB&resid=10C95EE5FD151BFB%21106&authkey=ACB6opQR3CG9kmc\" -O Dataset.tar.gz.aa\n",
"# !wget --no-check-certificate \"https://onedrive.live.com/download?cid=93DDDDD552E145DB&resid=93DDDDD552E145DB%21106&authkey=AP6EepjxSdvyV6Y\" -O Dataset.tar.gz.ab\n",
"# !wget --no-check-certificate \"https://onedrive.live.com/download?cid=644545816461BCCC&resid=644545816461BCCC%21106&authkey=ALiefB0kI7Epb0Q\" -O Dataset.tar.gz.ac\n",
"# !wget --no-check-certificate \"https://onedrive.live.com/download?cid=77CEBB3C3C512821&resid=77CEBB3C3C512821%21106&authkey=AAXCx4TTDYC0yjM\" -O Dataset.tar.gz.ad\n",
"# !wget --no-check-certificate \"https://onedrive.live.com/download?cid=383D0E0146A11B02&resid=383D0E0146A11B02%21106&authkey=ALwVc4StVbig6QI\" -O Dataset.tar.gz.ae\n",
"# !cat Dataset.tar.gz.* | tar zxvf -"
],
"execution_count": null,
"outputs": []
Expand Down
Binary file modified 范例/HW04/HW04.pdf
Binary file not shown.
Loading

0 comments on commit 744f777

Please sign in to comment.