Skip to content

Instantly share code, notes, and snippets.

View snakers4's full-sized avatar
🚀
It is by will alone I set my mind in motion.

Alexander Veysov snakers4

🚀
It is by will alone I set my mind in motion.
View GitHub Profile
FROM nvidia/cuda:8.0-cudnn6-devel
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:YOUR_PASSWORD' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
import torchvision.models as models
import torch
import torch.nn as nn
class FineTuneModel(nn.Module):
def __init__(self,
original_model,
arch,
num_classes,
freeze
@snakers4
snakers4 / Dockerfile
Last active February 22, 2018 09:30
Dockerfile update
# add 7z tar and zip archivers
FROM nvidia/cuda:9.0-cudnn7-devel
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:Ubuntu@41' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
@snakers4
snakers4 / multiprocessing_tqdm.py
Last active May 25, 2018 10:13
Using tqdm with multiprocessing
import tqdm
import pandas as pd
import numpy as np
from multiprocessing import Pool
import os
# drop all the unknown points and all closed points
# for each SK_ID_CURR calculate the counts of time in each status
# normalize by the max len (we know of) in any of the meaningful statuses
@snakers4
snakers4 / PyTorchMlP.py
Created May 28, 2018 07:48
Playing with MLP + embeddings in PyTorch
import torch
import torch.nn as nn
from torch.autograd import Variable
class NaiveClassifier(nn.Module):
def __init__(self,
cat_sizes=None,
numerical_features=117,
mlp_sizes=[1024,2048,1024,512,256,128,2],
embedding_factor=3,
@snakers4
snakers4 / Dockerfile
Created June 4, 2018 10:25
Atmyra Dockerfile
# add 7z tar and zip archivers
FROM nvidia/cuda:9.0-cudnn7-devel
# https://docs.docker.com/engine/examples/running_ssh_service/
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:Ubuntu@41' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
RUN mkdir ~/.ssh/
@snakers4
snakers4 / AttackerLoss.py
Created June 4, 2018 17:19
Loss for adversarial attacks
import torch
import torch.nn as nn
import torch.nn.functional as F
from utils.PyTorchSSIM import SSIM as SSIMLoss
class AttackerLoss(nn.Module):
def __init__(self,
gamma=0.9,
use_running_mean=False,
@snakers4
snakers4 / DS NN guidelines
Created October 19, 2017 07:39
Complete system installation for Data Science / Neural Networks from scratch / bare metal (assuming you have assembled the PC)
# BASIC SYSTEM SETUP
# First donwload Ubuntu iso file from https://www.ubuntu.com/download/desktop
# Use 16.04 LTS (17 is also ok, but it's better to use LTS versions, also 18 will be very mature in terms of systemd)
# Dowload Linux live USB creator and install the iso to your USB stick https://www.linuxliveusb.com
# Boot your system, go to BIOS on boot (usually Del) or boot menu (usually F12) and choose your USB stick as boot medium
# Install Linux (these steps can be omitted if clean Ubuntu installation is provided as service by admins / cloud provider / etc)
# Minor trick unplug ALL of your hard disks (unless you are an avanced user) except for the disk for your system
@snakers4
snakers4 / train.sh
Created July 7, 2018 11:34
VAE explanation bits
python3 train.py \
--epochs 30 --batch-size 512 --seed 42 \
--model_type fc_conv --dataset_type fmnist --latent_space_size 10 \
--do_augs False \
--lr 1e-3 --m1 40 --m2 50 \
--optimizer adam \
--do_running_mean False --img_loss_weight 1.0 --kl_loss_weight 1.0 \
--image_loss_type bce --ssim_window_size 5 \
--print-freq 10 \
--lognumber fmnist_fc_conv_l10_rebalance_no_norm \
@snakers4
snakers4 / pandas_multiprocessing_wrappers.py
Created December 14, 2018 12:07
Pandas multiprocessing wrappers
from tqdm import tqdm
import numpy as np
import pandas as pd
from multiprocessing import Pool
def _apply_df(args):
df, func, num, kwargs = args
return num, df.apply(func, **kwargs)
def apply_by_multiprocessing(df,func,**kwargs):