5 files changed
+318
-11
No files matched your search
+3
-3
@@ -6,12 +6,12 @@ hparams:
|
||||
lr: 0.001
|
||||
accumulate_grad_batches: 1
|
||||
gradient_clip_val: 0.5
|
||||
lin1_size: 256
|
||||
lin2_size: 256
|
||||
lin3_size: 128
|
||||
output_size: 10
|
||||
weight_decay: 0.000001
|
||||
split_ratio: 0.9
|
||||
lin1_size: 256
|
||||
lin2_size: 256
|
||||
lin3_size: 128
|
||||
|
||||
resume:
|
||||
resume_from_ckpt: False
|
||||
|
||||
@@ -0,0 +1,308 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Import modules from parent directory"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"is_executing": false
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# add directory above current directory to path\n",
|
||||
"import sys\n",
|
||||
"sys.path.insert(0, '..')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"is_executing": false
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# now we can import modules from parent directory\n",
|
||||
"import train\n",
|
||||
"import pipeline_modules"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Define function to print object length with commas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"2,395,940\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"showlen = lambda data: print(f\"{len(data):,}\")\n",
|
||||
"showlen([0 for i in range(2395940)])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Create quick progress bars with tqdm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
},
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"100%|█████████████████████████████████████████████████████████| 10/10 [00:10<00:00, 1.00s/it]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from tqdm import tqdm\n",
|
||||
"import time\n",
|
||||
"\n",
|
||||
"for i in tqdm(range(10)):\n",
|
||||
" time.sleep(1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"### Prettier ipywidgets version of the progress bar specifically for the notebook environment"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "5a5edf6f473c4a35961c7573fcbec317",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"HBox(children=(HTML(value=''), FloatProgress(value=0.0, max=10.0), HTML(value='')))"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from tqdm.auto import tqdm\n",
|
||||
"\n",
|
||||
"for i in tqdm(range(10)):\n",
|
||||
" time.sleep(1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"### Beyond basic for loops, you can also use it in list comprehensions"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "fd75636e82d84b76ac73ade86e3a8516",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"HBox(children=(HTML(value=''), FloatProgress(value=0.0, max=10.0), HTML(value='')))"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"some_list = [x**2 for x in tqdm(10*[0])]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"### You can even use it with multiprocessing\n",
|
||||
"https://stackoverflow.com/questions/41920124/multiprocessing-use-tqdm-to-display-a-progress-bar"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### If you’re iterating over a generator, tqdm won’t know the length and the progress bar will be more limited but if you know or can calculate the total length you can supply that as an argument"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "6f3a6d0f982e47c1b14c0e046997a44d",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"HBox(children=(HTML(value=''), FloatProgress(value=0.0, max=4.0), HTML(value='')))"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# generator expressions are surrounded by parenthesis ()\n",
|
||||
"generator = (x**2 for x in [1, 2, 3, 4])\n",
|
||||
"# print(next(generator))\n",
|
||||
"\n",
|
||||
"some_list = [x for x in tqdm(generator, total=4)]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Jupyter Notebook Shortcuts"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"- Esc will take you into command mode where you can navigate around your notebook with arrow keys.\n",
|
||||
"- While in command mode:\n",
|
||||
" - A to insert a new cell above the current cell, B to insert a new cell below.\n",
|
||||
" - M to change the current cell to Markdown, Y to change it back to code\n",
|
||||
" - D + D (press the key twice) to delete the current cell\n",
|
||||
" - Enter will take you from command mode back into edit mode for the given cell.\n",
|
||||
"- Shift + Tab will show you the Docstring (documentation) for the the object you have just typed in a code cell – you can keep pressing this short cut to cycle through a few modes of documentation.\n",
|
||||
"- Ctrl + Shift + - will split the current cell into two from where your cursor is.\n",
|
||||
"- Esc + O Toggle cell output.\n",
|
||||
"- Select Multiple Cells:\n",
|
||||
" - Shift + J or Shift + Down selects the next sell in a downwards direction. You can also select sells in an upwards direction by using Shift + K or Shift + Up.\n",
|
||||
" - Once cells are selected, you can then delete / copy / cut / paste / run them as a batch. This is helpful when you need to move parts of a notebook.\n",
|
||||
" - You can also use Shift + M to merge multiple cells."
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.7.7"
|
||||
},
|
||||
"pycharm": {
|
||||
"stem_cell": {
|
||||
"cell_type": "raw",
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"source": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 1
|
||||
}
|
||||
@@ -3,8 +3,7 @@ from pl_bolts.models.regression import LinearRegression, LogisticRegression
|
||||
from torch.nn.functional import one_hot
|
||||
import torch.nn.functional as F
|
||||
import pytorch_lightning as pl
|
||||
import torch
|
||||
import wandb
|
||||
|
||||
|
||||
# custom models
|
||||
from pipeline_modules.models import *
|
||||
|
||||
@@ -12,8 +12,8 @@ class SimpleLinearMNIST(nn.Module):
|
||||
super().__init__()
|
||||
|
||||
# mnist images are (1, 28, 28) (channels, width, height)
|
||||
self.model.fc = nn.Sequential(
|
||||
nn.Linear(self.model.fc.in_features, config["lin1_size"]),
|
||||
self.model = nn.Sequential(
|
||||
nn.Linear(28 * 28, config["lin1_size"]),
|
||||
nn.BatchNorm1d(config["lin1_size"]),
|
||||
nn.ReLU(),
|
||||
nn.Dropout(p=0.3),
|
||||
@@ -43,13 +43,12 @@ class EfficientNetPretrained(nn.Module):
|
||||
super().__init__()
|
||||
|
||||
self.model = EfficientNet.from_pretrained('efficientnet-b1')
|
||||
# self.model = EfficientNet.from_pretrained('efficientnet-b7')
|
||||
|
||||
for param in self.model.parameters():
|
||||
param.requires_grad = False
|
||||
|
||||
self.model.fc = nn.Sequential(
|
||||
nn.Linear(self.model.fc.in_features, config["lin1_size"]),
|
||||
self.model._fc = nn.Sequential(
|
||||
nn.Linear(self.model._fc.in_features, config["lin1_size"]),
|
||||
nn.BatchNorm1d(config["lin1_size"]),
|
||||
nn.ReLU(),
|
||||
nn.Dropout(p=0.25),
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
torchvision>=0.8.1
|
||||
pytorch-lightning>=1.0.6
|
||||
pytorch-lightning>=1.0.7
|
||||
pytorch-lightning-bolts>=0.2.5
|
||||
wandb>=0.10.10
|
||||
PyYAML>=5.3.1
|
||||
scikit-learn>=0.23.2
|
||||
efficientnet-pytorch>=0.7.0
|
||||
pandas>=1.1.4
|
||||
seaborn>=0.11.0
|
||||
Reference in new issue
Block a user