Skip to content

Instantly share code, notes, and snippets.

View ravnoor's full-sized avatar

Ravnoor Singh Gill ravnoor

View GitHub Profile
@ravnoor
ravnoor / Cats_vs_ Dogs_pytorch.py
Created February 19, 2018 16:43 — forked from fsodogandji/Cats_vs_ Dogs_pytorch.py
Unet Deeplearning pytorch
# from https://www.kaggle.com/nothxplz/dogs-vs-cats-redux-kernels-edition/cats-vs-dogs-05-pytorch-example/run/761413
from __future__ import print_function
import argparse
import csv
import os
import os.path
import shutil
import time
@ravnoor
ravnoor / data_loader.py
Created January 21, 2018 20:59 — forked from kevinzakka/data_loader.py
Train, Validation and Test Split for torchvision Datasets
# This is an example for the CIFAR-10 dataset.
# There's a function for creating a train and validation iterator.
# There's also a function for creating a test iterator.
# Inspired by https://discuss.pytorch.org/t/feedback-on-pytorch-for-kaggle-competitions/2252/4
from utils import plot_images
def get_train_valid_loader(data_dir,
batch_size,
augment,
@ravnoor
ravnoor / qholder.sh
Created November 11, 2017 21:05
hold and unhold queued jobs
# SGE 8.1.9
qhold 888333 -t 7-12
qalter -h U 888333 -t 7-12
@ravnoor
ravnoor / list-sort-unique.sh
Last active November 8, 2017 17:44
list, sort and unique to get directory name from filenames
ls -1 | awk -F'_' '{print $1 $2}' | sort -u
# FLP_001_t2.nii
# FLP_001_t1_nii
# FLP_004_t2.nii
# FLP_004_t1.nii
# ||
# ||
# FLP_001
# FLP_004
@ravnoor
ravnoor / volatility.py
Created September 19, 2017 17:07
Keras loss functions
# https://github.com/Rachnog/Deep-Trading/blob/master/volatility/volatility.py
epsilon = 1.0e-9
def qlike_loss(y_true, y_pred):
y_pred = K.clip(y_pred, epsilon, 1.0 - epsilon)
loss = K.log(y_pred) + y_true / y_pred
return K.mean(loss, axis=-1)
def mse_log(y_true, y_pred):
y_pred = K.clip(y_pred, epsilon, 1.0 - epsilon)
# https://github.com/andreimouraviev/Mets/blob/a8ce43b335584187f0728a4b3975c679ccf06cbc/UNET_2D_AUG17.py
# coding: utf-8
# In[1]:
import os
os.chdir(r'/home/amourav/Python')
import sklearn
from UTILS import *
@ravnoor
ravnoor / tensorflow-build.sh
Last active August 29, 2017 19:46
Build tensorflow from source on Ubuntu 14.04
conda create -n tf-keras python=2.7
pip install numpy
wget https://github.com/bazelbuild/bazel/releases/download/0.5.2/bazel-0.5.2-installer-linux-x86_64.sh
# 0.5.4 incompatibility issues
chmod +x bazel-0.5.2-installer-linux-x86_64.sh
HOME=/00_toolbox ./bazel-0.5.2-installer-linux-x86_64.sh --prefix=/00_toolbox/bazel-build
git clone https://github.com/tensorflow/tensorflow
@ravnoor
ravnoor / Documentation.md
Created August 23, 2017 16:18 — forked from KartikTalwar/Documentation.md
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@ravnoor
ravnoor / remove-hidden-junk
Created August 22, 2017 18:33
remove hidden junk files generated via mountain-duck SSH mounting connections
find . -maxdepth 1 -name '._*' -delete
@ravnoor
ravnoor / python-parfor.py
Created July 4, 2017 15:10 — forked from jasimpson/python-parfor.py
Example code to demonstrate parallel for (parfor) loop implementation using joblib
# Example code to demonstrate parallel for loop implementation using joblib
from joblib import Parallel, delayed
import multiprocessing
# Vars
my_list = range(10)
squares = []
# Function to parallelize
def find_square(i):