Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# https://www.cointribune.com/en/columns/the-defi-column/has-pancake-bunny-fallen-victim-to-a-1-billion-hack/ | |
# | |
# Panoramix 17 Feb 2020 | |
# | |
# | |
# I failed with these: | |
# - unknownee872558(?) | |
# All the rest is below. | |
# |
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
# adapted from: https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/blob/master/test.py | |
for epoch in range(opt.epoch_count, opt.n_epochs + opt.n_epochs_decay + 1): # outer loop for different epochs; we save the model by <epoch_count>, <epoch_count>+<save_latest_freq> | |
epoch_start_time = time.time() # timer for entire epoch | |
iter_data_time = time.time() # timer for data loading per iteration | |
epoch_iter = 0 # the number of training iterations in current epoch, reset to 0 every epoch | |
visualizer.reset() # reset the visualizer: make sure it saves the results to HTML at least once every epoch | |
model.update_learning_rate() # update learning rates in the beginning of every epoch. | |
for i, data in enumerate(dataset): # inner loop within one epoch |
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
from sklearn.ensemble import RandomForestRegressor | |
import xgboost as xgb | |
import lightgbm as lgb | |
def rmspe_calc(y_true, y_pred): | |
# Compute Root Mean Square Percentage Error between two arrays. | |
return np.sqrt(np.mean(np.square(((y_true - y_pred) / y_true)), axis=0)) | |
models = [ |
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
from itertools import product | |
from tqdm.notebook import tqdm | |
def get_learner(emb_szs=emb_szs, layers=[1000,500], ps=[0.02,0.04], emb_drop=0.08): | |
return (tabular_learner(data, | |
layers=layers, | |
ps=ps, | |
emb_drop=emb_drop, | |
y_range=y_range, |
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
# Fill Missing values | |
# Encode categorical variables | |
# Normalize continous variables | |
procs=[FillMissing, Categorify, Normalize] | |
cont_vars = [i for i in [‘checkout_price’, | |
‘base_price’, | |
‘Elapsed’, | |
‘week_sin’, | |
‘week_cos’, |
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
# taken from: https://github.com/alishdipani/Neural-Style-Transfer-Audio/blob/master/NeuralStyleTransfer.py | |
if torch.cuda.is_available(): | |
output = output.cpu() | |
output = output.squeeze(0) | |
output = output.numpy() | |
N_FFT=2048 | |
a = np.zeros_like(output) |
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 torch | |
import torch.nn as nn | |
from torch.nn import Conv2d, ReLU, AvgPool1d, MaxPool2d, Linear, Conv1d | |
from torch.autograd import Variable | |
import torch.optim as optim | |
import numpy as np | |
import os | |
import torchvision.transforms as transforms | |
import gc; gc.collect() |
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 torch | |
import torch.nn as nn | |
from torch.nn import ReLU, Conv1d | |
import torch.optim as optim | |
import numpy as np | |
import copy | |
class CNNModel(nn.Module): | |
def __init__(self): | |
super(CNNModel, self).__init__() |
NewerOlder