Skip to content

Instantly share code, notes, and snippets.

View arunreddy's full-sized avatar
🎯
Focusing

Arun Reddy arunreddy

🎯
Focusing
View GitHub Profile
@arunreddy
arunreddy / splitPosAndNeg.jl
Last active October 21, 2015 02:32
Replacing negative values with zeroes.
a = [1 -2 ; -3 4];
aPos = (a.>0.0).*a;
aInd = (a.<0.0).*a*-1;
@arunreddy
arunreddy / arch-linux-install
Created December 5, 2015 04:06 — forked from mattiaslundberg/arch-linux-install
Minimal instructions for installing arch linux on an UEFI system with full system encryption using dm-crypt and luks
# Install ARCH Linux with encrypted file-system and UEFI
# The official installation guide (https://wiki.archlinux.org/index.php/Installation_Guide) contains a more verbose description.
# Download the archiso image from https://www.archlinux.org/
# Copy to a usb-drive
dd if=archlinux.img of=/dev/sdX bs=16M && sync # on linux
# Boot from the usb. If the usb fails to boot, make sure that secure boot is disabled in the BIOS configuration.
# Set swedish keymap
@arunreddy
arunreddy / ldaSynthData.jl
Created December 22, 2015 18:22
Synthetic Data using LDA Generative Model
using PyPlot;
using Distributions;
TOPIC_N = 5;
VOCABULARY_SIZE = 1000;
DOC_NUM = 100;
TERM_PER_DOC = 200;
X = zeros(DOC_NUM,VOCABULARY_SIZE);
@arunreddy
arunreddy / qsub.py
Last active May 17, 2016 15:20 — forked from astrofrog/qsub.py
Submitting jobs via qsub in Python
import os
import random
import string
import tempfile
import subprocess
def random_id(length=8):
return ''.join(random.sample(string.ascii_letters + string.digits, length))
TEMPLATE_SERIAL = """
@arunreddy
arunreddy / keybase.md
Created August 3, 2016 22:19
keybase.md

Keybase proof

I hereby claim:

  • I am arunreddy on github.
  • I am arunreddy (https://keybase.io/arunreddy) on keybase.
  • I have a public key whose fingerprint is 70DE 4849 57EB F197 1C6C B887 AB43 972A 33B0 3B5C

To claim this, I am signing this object:

/**
* Stochastic Gradient Descent is a technique for minimizing a function which
* can be expressed as a sum of other functions. That is, suppose we have
*
*/
class SGDMomentum{
public:
/**
* Constructor
@arunreddy
arunreddy / momentum.cpp
Last active March 2, 2017 02:36
Momentum
// Without policy class..
Optimize(arma::mat& iterate){
arma::mat v = arma::zeros<arma::mat>(iterate.n_rows, iterate.n_cols);
for(;;){
v = momentum*v - stepSize * gradient;
iterate += v;
}
StandardSGD <LogisticRegressionFunction<>> sgdOpt(lrf);
sgdOpt.MaxIterations() = maxIterations;
sgdOpt.Tolerance() = tolerance;
sgdOpt.StepSize() = stepSize;
Log::Info << "Training model with SGD optimizer." << endl;
// This will train the model.
model.Train(sgdOpt);
@arunreddy
arunreddy / logistic_regression_mlplack.cpp
Last active March 5, 2017 23:27
Logistic Regression MLPACK.
// logistic_regression_test.cpp Lines[504-512]
// Very simple fake dataset.
arma::mat data("1 2 3;"
"1 2 3");
arma::Row<size_t> responses("1 1 0");
// Create a logistic regression object using a custom SGD object with a much
// smaller tolerance.
LogisticRegressionFunction<> lrf(data, responses, 0.001);
@arunreddy
arunreddy / policy_types.cpp.cpp
Created March 6, 2017 05:46
policy_types.cpp created by arunreddy - https://repl.it/GIX8/0
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World" << endl;
return 0;
}