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
sudo apt update && sudo apt upgrade -y | |
sudo apt -y install build-essential git zsh python3-pip gnome-shell-extension-manager openssh-server curl nodejs htop mdadm ffmpeg lm-sensors npm tree | |
sudo apt -y install linux-headers-$(uname -r) | |
sudo apt-key del 7fa2af80 | |
# Latest driver download | |
# https://www.nvidia.co.uk/download/driverResults.aspx/205541/en-uk | |
wget https://uk.download.nvidia.com/XFree86/Linux-x86_64/535.54.03/NVIDIA-Linux-x86_64-535.54.03.run |
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 numpy as np | |
import matplotlib.pyplot as plt | |
import random | |
import matplotlib.animation as animation | |
from matplotlib import cm | |
# s curve function | |
def _f(a,b,c,t): | |
return c*1/(1+a*np.exp(-b*t)) | |
# function for s curve with added noise |
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
class HardMiningBatchSampler(BatchSampler): | |
""" | |
Creates batches that only contain a class once and and chosen based on embedding distance. | |
Used for NPairLoss | |
""" | |
def __init__(self, labels, batch_size, drop_last=True, classes=None): | |
self.labels = labels | |
self.batch_size = batch_size | |
# self.C = batch_size * 2 if classes is None else classes |
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 category_encoders import utils | |
from sklearn.base import BaseEstimator, TransformerMixin | |
from sklearn.model_selection import StratifiedKFold | |
import category_encoders as encoders | |
import pandas as pd | |
import numpy as np | |
import copy | |
class NestedCVWrapper(BaseEstimator, TransformerMixin): |
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 numpy as np | |
import pandas as pd | |
import os | |
import matplotlib.pyplot as plt | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torch.optim as optim | |
from torch.utils.data import Dataset, DataLoader |
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
""" | |
Implementation of DDPG - Deep Deterministic Policy Gradient | |
Algorithm and hyperparameter details can be found here: http://arxiv.org/pdf/1509.02971v2.pdf | |
Variance scaling paper: https://arxiv.org/pdf/1502.01852v1.pdf | |
Thanks to GitHub users yanpanlau, pemami4911, songrotek and JunhongXu for their DDPG examples | |
Batch normalisation on the actor accelerates learning but has poor long term stability. Applying to the critic breaks | |
it, particularly on the state branch. Not sure why but I think this issue is specific to this environment | |
""" | |
import numpy as np |