This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
urls = Array.from(document.querySelectorAll('.rg_di .rg_meta')).map(el=>JSON.parse(el.textContent).ou); | |
window.open('data:text/csv;charset=utf-8,' + escape(urls.join('\n'))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import json | |
import itertools | |
import urllib | |
import requests | |
import os | |
import re | |
import sys | |
print("hah") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this snippet into your Kaggle kernel, make sure the file is under kaggle/working/ | |
import os | |
os.chdir(r'kaggle/working/') | |
from IPython.display import FileLink | |
FileLink(r'export.pkl') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import standard PyTorch modules | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torch.optim as optim | |
from torch.utils.tensorboard import SummaryWriter # TensorBoard support | |
# import torchvision module to handle image manipulation | |
import torchvision | |
import torchvision.transforms as transforms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use standard FashionMNIST dataset | |
train_set = torchvision.datasets.FashionMNIST( | |
root = './data/FashionMNIST', | |
train = True, | |
download = True, | |
transform = transforms.Compose([ | |
transforms.ToTensor() | |
]) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build the neural network, expand on top of nn.Module | |
class Network(nn.Module): | |
def __init__(self): | |
super().__init__() | |
# define layers | |
self.conv1 = nn.Conv2d(in_channels=1, out_channels=6, kernel_size=5) | |
self.conv2 = nn.Conv2d(in_channels=6, out_channels=12, kernel_size=5) | |
self.fc1 = nn.Linear(in_features=12*4*4, out_features=120) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import modules to build RunBuilder and RunManager helper classes | |
from collections import OrderedDict | |
from collections import namedtuple | |
from itertools import product | |
# Read in the hyper-parameters and return a Run namedtuple containing all the | |
# combinations of hyper-parameters | |
class RunBuilder(): | |
@staticmethod | |
def get_runs(params): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Helper class, help track loss, accuracy, epoch time, run time, | |
# hyper-parameters etc. Also record to TensorBoard and write into csv, json | |
class RunManager(): | |
def __init__(self): | |
# tracking every epoch count, loss, accuracy, time | |
self.epoch_count = 0 | |
self.epoch_loss = 0 | |
self.epoch_num_correct = 0 | |
self.epoch_start_time = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put all hyper params into a OrderedDict, easily expandable | |
params = OrderedDict( | |
lr = [.01, .001], | |
batch_size = [100, 1000], | |
shuffle = [True, False] | |
) | |
epochs = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m = RunManager() | |
# get all runs from params using RunBuilder class | |
for run in RunBuilder.get_runs(params): | |
# if params changes, following line of code should reflect the changes too | |
network = Network() | |
loader = torch.utils.data.DataLoader(train_set, batch_size = run.batch_size) | |
optimizer = optim.Adam(network.parameters(), lr=run.lr) |
OlderNewer